To group data, every time there's a "new person" as below, I want to add their info to that temporary array and reset that array to null.
Before each "new person" array is set to null, I want to add that array to an array of people. An array of arrays.
How can I add one array into another?
$people = import-csv "./people.csv"
$h = @{}
$h.gettype()
$all_people
ForEach ($person in $people) {
$new_person
if ($person -match '[0-9]') {
Write-host $person
}
else {
write-host "new person"
write-host $person
}
}
output:
thufir@dur:~/flwor/people$
thufir@dur:~/flwor/people$ pwsh foo.ps1
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Hashtable System.Object
new person
@{people=joe}
@{people=phone1}
@{people=phone2}
@{people=phone3}
new person
@{people=sue}
@{people=cell4}
@{people=home5}
new person
@{people=alice}
@{people=atrib6}
@{people=x7}
@{people=y9}
@{people=z10}
thufir@dur:~/flwor/people$
I have something like this:
$people = import-csv "./people.csv"
$all_people
$new_person = "new","person"
$new_person.GetType()
ForEach ($person in $people) {
if ($person -match '[0-9]') {
Write-host $person
$new_person.Add($person)
}
else {
write-host "new person"
write-host $person
#$new_person = null
$new_person = "new","person"
}
}