powershell importing multidimensional arrays properly

jlo

Member
im trying to import multidimensional arrays using import-csv but its not working properly...
---csv contents
psn,TYPE,asset,23-Jun,24-Jun,25-Jun
jlo,"(cd,album)",nin,TRUE,TRUE,TRUE
abc,tape,"(metallica, rage)",TRUE,TRUE,FALSE
aaa,cd,rhcp,TRUE,FALSE,TRUE
"(jlo, aaa)",concert,santana,FALSE,TRUE,FALSE
---


$a
= @()
$a+=Import-Csvc:\temp\test.csv
$a[0][0] #doesnt work
$a[0,1] # lists entirety of lines 1 and 2 and not row 1 column 1 = (cd,album)
$a[0].Type #shows both values
$a | Where-Object {$_.psn -match"jlo"-and$_.type -match"cd"} #filters accuratly but not splitting TYPE field
$a | Where-Object {$_.psn -match"jlo"-and$_.type -match"cd"} | select psn, type |foreach {$_.type -split (", ")} | % {$_.trim("()")} # splits butdoesnt pass the rest of the info down the pipelines.
 
#goal 1: split multidimensional array by individual internal objects and output along with rest of the line.
#jlo, cd, nin, true...
#jlo, album, nin, true...
#abc, tape, metallica, true,true...
#abc, tape, rage, true, true

#goal 2: - split all and search accordingly
$date=Get-Date-Formatdd-MMM"6/24/2010"
$a | Where-Object {$_.type -match"concert"-and$_."$date"-match"true"} | select psn, type, asset#filters but doesnt split
#psn TYPE asset
#--- ---- -----
#jlo concert santana
#aaa concert santana
 
Last edited:

My Computer

Back
Top