ストリーム エディター sed を使用して、大量のテキスト ファイル データ (400MB) を csv 形式に変換しています。
私は終わりに非常に近づいていますが、未解決の問題は、次のようなデータの引用符内の引用符です。
1,word1,"description for word1","another text",""text contains "double quotes" some more text"
2,word2,"description for word2","another text","text may not contain double quotes, but may contain commas ,"
3,word3,"description for "word3"","another text","more text and more"
望ましい出力は次のとおりです。
1,word1,"description for word1","another text","text contains double quotes some more text"
2,word2,"description for word2","another text","text may not contain double quotes, but may contain commas ,"
3,word3,"description for word3","another text","more text and more"
ヘルプを探しましたが、解決策に近づきすぎていません。正規表現パターンを使用して次の sed を試しました。
sed -i 's/(?<!^\s*|,)""(?!,""|\s*$)//g' *.txt
sed -i 's/(?<=[^,])"(?=[^,])//g' *.txt
これらは以下の質問からのものですが、sed では機能していないようです:
元のファイルは *.txt で、sed でその場で編集しようとしています。