3

I tried to export a mysql table into csv file, the table contains wild character such as newline in several columns. The following csv file shows column improperly separated when opening in excel/csved, what's wrong?

SELECT * INTO OUTFILE 'table.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' escaped by '\\' LINES TERMINATED BY '\n'  FROM mytable limit 10
2
  • Can you connect to your db from Excell with ODBC? This should be much easier to get right than CSV. Commented Jan 14, 2012 at 2:01
  • @Andrew: the remote db is too large(TBs) to be directly exported from excel. and the process needs to be scripted in linux shellscript Commented Jan 14, 2012 at 2:11

1 Answer 1

0

During the export process of mysql you can suggest an alternate field separator, rather than a comma. Just select a character(s) that is unlikely to appear in any of your output fields ~ personally iI have done this and selected a couple of characters together, such as '£€£'.

Then. When you open the file in xl you can tell xl what the field and line separators are.

The info for the export syntax can be found with the load data on file documentation.

https://dev.mysql.com/doc/refman/5.7/en/load-data.html

David.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.