0

I have MySQL table with columns (character-set: utf8, collation: utf8mb4_unicode_ci) to be exported to a .csv file.

mysqldump -u *** -p -t -T/tmp/ dbname tablename --default-character-set=utf8mb4

The output has more lines than the records in the table due to some symbols? characters? to break the lines incorrectly. (see pics below) Adding "enclosed by" or "escaped by" do not help.

column

output

  • Did you have your problem solved? – joanolo Apr 2 '17 at 11:08
0

The CSV "de facto standard" allows for fields to contain line breaks. So, what you get is the result of some of your data in your original table containing line breaks.

When that's the case, one record uses more than one row of text.

Some libraries or some programs can handle and interpret that adequately, but not all do. For instance, you can use MS Access, and it will work; but if you try MS Excel, line breaks within a field won't be properly handled. If you work with MySQL or PostgreSQL, they can import/export CSV with line breaks in fields.

Check, for instance, Comma-separated values at WikiPedia or RFC 4180

Fields with embedded line breaks must be quoted (however, many CSV implementations do not support embedded line breaks).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.