本文介绍了从CSV中剥离额外文本限定符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



请注意,每个整数(例如1,2 ,3 etc)应该是一个字符串,合格的字符串被符号包围。

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

注意最后一个合格的字符串是否有一个符号作为字符串的一部分。



自动清除CSV以消除冗余的限定符?



我可以使用以下技术:POSH / BAT脚本,VBA,Access。 >

解决方案

这样可能吗?

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


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

这篇关于从CSV中剥离额外文本限定符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:29