To create two csv-files:
echo -e "123\n456" > t0.txt
echo -e '"foo","bar"\n"foo\"bar\"","baz"' > t1.txt
Now, I want append the columns in t1.txt
to t0.txt
, so that the result becomes this:
123,"foo","bar"
456,"foo\"bar\"","baz"
First try, using csvtool
csvtool paste t0.txt t1.txt
Fatal error: exception Csv.Failure(2, 1, "Bad '"' in quoted field")
So, csvtool
doesn't seem to handle the escaped quotation mark in "foo\"bar\""
.
My real world use case has two CSV-files with +150.000.000 rows and 11 columns so I need a tool which can do the task without having all the data simultaneously in RAM.
Can csvtool be used with escaped quotation marks, or is there another tool that could solve this?
The final target for the CSV-file is a database in mariadb
, so an efficient import to mariadb
using t0.txt
and t1.txt
directly would be even better, but as far as I know LOAD DATA INFILE
only works on a single CSV-file.
I definitely prefer a ready-made tool, but if there is none, then some C, Perl or Python snippets would be appreciated too.