MySQL: Remove line breaks before CSV export
Tip by Axuter | 2012-02-09 at 16:19
If you want to export the data from a MySQL table to a CSV file, often line breaks are making trouble. Because newlines are interpreted as the end of a row within the CSV file, we can quickly destroy the export data.
UPDATE tab SET col = replace(col, CHAR(13,10), '');
This brief MySQL command brings everything in order. It replaces in the column "col" of the table "tab" all line breaks with nothing, so that in other words, all line breaks will be deleted from this column.
Because under circumstances, with this command, non-contiguous words may be joined (if they were previously only separated with a line break), you can also replace with ' ' alternatively. Sometimes, it would even be a good idea to replace with a wildcard character, so that the line breaks can be restored later.
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
MySQL: CSV Export as automatic Download
Tutorial | 0 Comments
MySQL: CSV Export as File stored on the Server
Tutorial | 0 Comments
Units: SI Prefixes for Powers of Ten
Info | 0 Comments
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
MySQL: Delete Data from Table - Difference between TRUNCATE, DELETE and DROP
Tutorial | 0 Comments
Convert many CSV Files to XLSX or ODS Spreadsheets
Tutorial | 0 Comments
PHP: Remove arbitrary Characters at the Beginning and the End of a String
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.