【发布时间】:2015-09-16 14:48:18
【问题描述】:
我有一个 CSV 文件,其中的文本列用单引号括起来,而其他非文本列周围没有引号。文本列在这些单引号文本列中可能有逗号或单引号。我在网上找到了一个脚本,但它不能处理这种情况。
有没有办法在 PowerShell 中处理这个问题?
例子:
123,678.89,'hello there1', 'xyz1@gmail.com', 'abc,nds'\n
123,678.89,'hello 'there2', 'xyz2@gmail.com', 'akiu-'nds'\n
输出:
123,678.89|hello there1|xyz1@gmail.com|abc,nds \n
123,678.89|hello 'there2|xyz2@gmail.com|akiu-'nds \n
示例 2:
123,6272,678.89,,,'hello ,there1',,,,'abc1','tw,es',,'xyz1@gmail.com',,,,,,'abc,nds1'\n
124,8272,928.89,,,,'hello 'there2',,,'abc2','twes',,,'xyz2@gmail.com',,'biej',,,'abc'nds2'\n
125,9272,328.89,,'你好'there3',,'abc3',',outyi',,,,'xyz3@gmail.com',,,,,,'ahct','abc'nds3'\n
输出:
123|6272|678.89|||你好,there1||||abc1|tw,es||xyz1@gmail.com||||||abc,nds1\n 124|8272|928.89||||你好'there2|||abc2|twes|||xyz2@gmail.com||biej|||abc'nds2\n 125|9272|328.89||你好'there3||abc3|, outyi||||xyz3@gmail.com||||||ahct|abc'nds3\n
【问题讨论】:
标签: string powershell csv