で構成されるフィールドを含むテキストファイルがあります。これを一般的なCSV|
に変換したいと思います。,
私はこれを使ってみました:
sed 's/|/,/g' test.txt > test.csv
ただし、一部のフィールドにはすでにカンマがあります。たとえば、
var1|var2|var3
Potter, Harry|2|3
どうすればいいですか?
ベストアンサー1
正しいcsvパーサーツールを使用してください。
csvtool -t '|' -u ',' cat infile > outputfile
var1,var2,var3
"Potter, Harry",2,3
からcsvtool --help
:
-t Input separator char. Use -t TAB for tab separated input.
-u Output separator char. Use -u TAB for tab separated output.
cat
This concatenates the input files together and writes them to
the output. You can use this to change the separator character.