loops

Powershell reading multiple variables from text file

孤街浪徒 提交于 2021-02-08 10:20:27
问题 I'm quite new to PS, so please don't kill me if the resolution is so easy :) I've tried to find a solution here and in google, but no luck. This is part of code which don't work as I want $Contents = Get-Content "Path\test.txt" foreach($Line in $Contents) { $Line = $Line.split(":")[1] $s = $line -split ':' $RegPath = $s[0] $Value_Name = $s[1] $Type = $s[2] $Value = $s[3] Write-host $RegPath $Value_Name $Type $Value } The output from Write-Host is ok, but the main problem is when I want to use

Powershell reading multiple variables from text file

拈花ヽ惹草 提交于 2021-02-08 10:20:16
问题 I'm quite new to PS, so please don't kill me if the resolution is so easy :) I've tried to find a solution here and in google, but no luck. This is part of code which don't work as I want $Contents = Get-Content "Path\test.txt" foreach($Line in $Contents) { $Line = $Line.split(":")[1] $s = $line -split ':' $RegPath = $s[0] $Value_Name = $s[1] $Type = $s[2] $Value = $s[3] Write-host $RegPath $Value_Name $Type $Value } The output from Write-Host is ok, but the main problem is when I want to use

How to transform a data frame into a list in r?

五迷三道 提交于 2021-02-08 10:19:05
问题 Could you please help me? I want to make a list based on information contained in an R data frame. I found a solution, but it is not general. For instance, let's start with this data frame: df <- data.frame(vertices = paste(letters[1:20]), modules = rep(1:4, 5)) I want to use df$modules to turn the data frame into a list. The items of the list should contain data from df$vertices . So I found this solution: list1 <- split(df, df$modules) list2 <- vector(mode = "list", length = length(unique

Node js infinite loop

岁酱吖の 提交于 2021-02-08 10:17:44
问题 I have a node server that pulls info from a php server and sends it over where it needs to be through a callback. Once or twice ad day the server gets stuck in an infinite loop and I think it's because I'm not properly handling the connection between the the php and node server. I posted my authentication code below. Anyone have any ideas? exports.authenticate = function(request, callback) { var https = require('https'); var options = { hostname: 'www.mysite.com', port: 443, path: '/site

How to find ASCII of every character in string using DB2 Function?

♀尐吖头ヾ 提交于 2021-02-08 08:52:20
问题 I have written a function in DB2 - that is calculating ASCII of records in a particular column. I want to some help as I want to check the ASCII of every single character in string return yes if the ASCII of that record is greater than 127. BEGIN ATOMIC DECLARE POS, INT; IF INSTR IS NULL THEN RETURN NULL; END IF; SET ( POS, LEN )=( 1, LENGTH(INSTR) ); WHILE POS <= LEN DO IF ASCII( SUBSTR( INSTR, POS, 1 ))> 128 THEN RETURN 'Y'; END IF; SET POS = POS + 1; END WHILE; RETURN 'N'; 回答1: Why to

Why my Java while loop iterates half times [duplicate]

℡╲_俬逩灬. 提交于 2021-02-08 08:26:22
问题 This question already has answers here : BufferedReader is skipping every other line when reading my file in java (3 answers) Closed 1 year ago . //some code here String x; while ((x = inputStream.readLine()) != null) { System.out.println(inputStream.readLine()); } inputStream.close(); } Hello I am beginner at Java and My while loop should give an output like aaasd1 aaasd2 aaasd3 aaasd4 aaasd5 aaasd6 But it gives aaasd2 aaasd4 aaasd6 When i change the println to System.out.println(x); it

Looping through n x n matrix with a smaller matrix of certain size with numpy arrays

北慕城南 提交于 2021-02-08 08:23:39
问题 I'm currently having the following issue, given an array let's say for simplicity a 4 x 4 array (I'm actually working with 512 x 512 ) X = np.array([[3, 5, 2, 4], [7, 6, 8, 8], [1, 6, 7, 7], [2, 1, 3, 4]]) I would like to loop/slide around the array in a way that I can save new arrays in the form np.array([3,5],[7,6]), np.array([2,4], [8,8]), np.array([1,6],[2,1]), np.array ([7,7],[1,4]) and so on (Ideally that I could choose the step and the size of my "sliding" window). Also I would like to

R Plotly Add Trace within Loop

时光毁灭记忆、已成空白 提交于 2021-02-08 08:13:26
问题 I have an issue with using loops to add trace in plotly, though I have no idea what the cause is. If I try to make a plot using the method for P below, only the data for last column (HORSE) is shown. Rabbit and Dog still show up, but both display values for Horse. If, however, I use the P1 method the graph works perfectly. I would really like to be able to do this within a loop as the length of columns varies. df <- data.frame(AGE = c(0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3

R - loop and break after value found for each Rows

此生再无相见时 提交于 2021-02-08 08:00:13
问题 I have a matrix of 0-1. What I would like to do is to loop into this matrix and search for the 1. Each time a 1 has been found, to simply jump or pass that row, in order to only record 1 value per row. What I am trying to know if the first episode of the sequence is a 1 . I was thinking there might be a solution with break But I am unsure how to use it properly. So this is my first matrix SoloNight = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,

R - loop and break after value found for each Rows

淺唱寂寞╮ 提交于 2021-02-08 08:00:08
问题 I have a matrix of 0-1. What I would like to do is to loop into this matrix and search for the 1. Each time a 1 has been found, to simply jump or pass that row, in order to only record 1 value per row. What I am trying to know if the first episode of the sequence is a 1 . I was thinking there might be a solution with break But I am unsure how to use it properly. So this is my first matrix SoloNight = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,