简体   繁体   中英

stripping extra text qualifier from a CSV

I have a CSV that has certain fields separated by the " symbol as a TextQualifier.

See below for example. Note that each integer (eg. 1,2,3 etc) is supposed to be a string. the qualified strings are surrounded by the " symbol.

1,2,3,"qualifiedString1",4,5,6,7,8,9,10,11,12,13,14,15,16,"qualifiedString2""

Notice how the last qualified string has a " symbol as part of the string.

Can you suggest an elegant way to automate the cleaning of the CSV to eliminate redundant " qualifiers?

I have the following technologies at my disposal: POSH/BAT scripting, VBA, Access.

Something like this, perhaps?

(get-content file.txt -ReadCount 0) -replace '([^,]")"','$1' |
 set-content newfile.txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM