powershell - Import-CSV returns null when piped files -


i have piece of code should grab .csv files out of directory , import them, using pipe character delimiters.

$apeasy = dir .\apeasy\*.csv | import-csv -delimiter '|' 

the problem returns null. without exception, no matter do. weird thing works:

dir .\apeasy\*.csv 

it returns fileinfo object, should getting piped import-csv file import. in addition, these 2 commands work:

$csvfiles = dir .\processed_data_review -filter *.txt | import-csv -header(1..19) -delimiter "$([char]0x7c)" dir .\lims -filter *.csv | import-csv | ? {$_.samplename -like "????-*"}| export-csv -path .\lims_output.txt -notypeinformation 

i have no idea what's going on here. i'm dealing basic pipe-delimited file, quotations around every field (which fine, can import data those). nothing special going on here. file there, import-csv isn't getting reason.

so question this: cause file grabbed 'dir' fail piped import-csv?

edit: overall goal of read csv files in directory without knowing name in advance, , output specific columns variety of output files.

edit: line of code stands right now:

$apeasy = get-childitem .\apeasy\*.csv | select-object -expandproperty fullname | import-csv -delimiter "$([char]0x7c)" 

isolating get-childitem statement, , isolating get-child , select-object both return should. list of csv files in directory, , array of full paths, respectively. still, when piped import-csv, dissappear. get-member on variable returns it's empty.

import-csv accepts strings (path) pipeline in order pipe directly need first expand paths:

dir .\apeasy\*.csv |  select -expand fullname | import-csv -delimiter '|' 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -