So, I have a single large string that looks something like:
Date, Status, Data
More Data about above line
Date, Status, Data
More Data about above line
Date, Status, Data
More Data about above line
Date, Status, Data
More Data about above line
Date, Status, Data
More Data about above line
And so forth. I’ve converted this into an array, but you might see the issue based on the information above.
The array now looks like:
$array[0]
Date, Status, Data
$array[1]
More Data about above line
I would like to take every two lines in the large string and make that a single entry into the array, so it looks like:
$array[0]
Date, Status, Data
More Data about the above line
Is there a simple way to do this?
This is the code I’m using to split it up from a large string to array:
$in = "your text"
$lines = $in.Split([Environment]::NewLine) | ? { $_ -ne "" }
The above examples explain pretty well what I’m seeing. I’m able to tear the large string apart and stuff it into an array, but the output is less than ideal, because I want every two lines in the large string grouped into a single array entry.
Josh B is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1