If my input file is delimited by a vertical Bar(|) and data has 2 sets of double quotes around data values would I need
to do anything special other than specify the deliminator when reading the records?
Data:
Fileseq|recordnbr|specnbr
""001""|""1""|""cs445""
The first record is the header record.
Thanks.
My script is doing this...
Import-CSV $file -delimiter '|' | ForEach-Object{
Now that the data has 2 sets of Double quotes it's not reading formatting data correctly based upon header column. Is there anyway to parse or ignore the double quotes and just process data between Bar delims.
I also found some data records that had
"001|""2"|"cs446""
Thanks.
"001|""2"|"cs446""
This one's a problem. Having only an opening quotation mark, but no closing quote before the pipe symbol is a mess. If none of your data fields will contain a pipe symbol, I'd recommend just stripping all of the double quotes out of the file's contents before treating it as CSV data, like this:
$content = Get-Content -Path $file $content = $content -replace '"','' $content | ConvertFrom-Csv -Delimeter '|' | ForEach-Object { # do stuff }
How does that logic get implemented into my current script...
Will that replace work for multiple files found during processing?
ForEach($file in $files){
Write-Log "$writelogdir\files-processed.log" "Found files $file"
Import-CSV $file -delimiter '|' | ForEach-Object{
# I have a bunch of Do things
Thanks.
Yep ... it worked great !!!!
Thanks.