[MariaDB] Calc-friendly way to export to CSV?

Hello,

I’m trying the following command in MariaDB to export a table in CSV before reading it in Calc.

SELECT * from mytable INTO OUTFILE '/tmp/test.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Problem is, although double quoted, some columns contain carriage returns –— \0A, like the final CR between each row —, and Calc gets confused for some reason.

Am I doing it wrong?

Thank you.

It may be easier to connect Base to your MariaDB. Then you can drag a table or query directly to Calc.
.
Line breaks inside data/columns should be avoided… So I never tried this. Can you provide an example file for testing? I would usually mask/replace the line-break with a pattern like _%10_ to be replaced again after import.
.
CR/LF is usually no problem. As it is the typical line-end on DOS/Windows, most programs know how to handle this.

Unfortunately, some columns must hold carriage returns since they’re articles.

But I’m surprised Calc fails parsing since the columns are all double quoted, with double quotes within columns escaped (ie. “”) as they should be.

I’ll try something else. Thank you.

MySQL (and by transition, MariaDB) CSV generator is … strange, to say the least. Here is my blog post about my own struggle to get a “standard” CSV out of its generator…

Anyway, it would be nice to have a sample CSV that Calc fails to process, to see the actual problem - could it really be some bug in Calc, that could be fixed with the help of the sample?

1 Like