1

I'm trying to get data out of MySQL table and into a csv so I can edit in Excel.

There is a note field that is extremely long and has a ton of different characters.

When I open the file in excel it throws the data all out of place. Any ideas on how to get this file out of mysql and keep all the rows aligned?

Please and thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

1

A good practice in this case might be to normalize the data in the notes field? REPLACE(REPLACE(table.notes, '\r', ''), '\n', '')

Greg_D
  • 150
  • 7
0

Use the query below

LOAD DATA INFILE 'data.csv' INTO TABLE tbl_name
FIELDS ENCLOSED BY '#' TERMINATED BY ';'  LINES TERMINATED BY '\r\n';

Note

For a text file generated on a Windows system, proper file reading might require LINES TERMINATED BY '\r\n' because Windows programs typically use two characters as a line terminator. Some programs, such as WordPad, might use \r as a line terminator when writing files. To read such files, use LINES TERMINATED BY '\r'.

More details can be found in the MYSQL documentation.