You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Emmanuel Bourg (JIRA)" <ji...@apache.org> on 2014/01/23 10:41:41 UTC

[jira] [Updated] (CSV-35) Escaped line separators are not supported

     [ https://issues.apache.org/jira/browse/CSV-35?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Bourg updated CSV-35:
------------------------------

    Attachment: mysql-export-line-terminated-by-crlf.csv
                mysql-export-line-terminated-by-lf.csv

I attached two files exported from MySQL 5.1. The source table contains 3 columns.

In the first file the records are terminated by LF. If a field contains CRLF MySQL generates CR<escape>LF. The file was created with this query:

{code}
SELECT * INTO OUTFILE '/mysql-export-line-terminated-by-lf.csv' FIELDS TERMINATED BY ';' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM test
{code}

In the second file the records are terminated by CRLF. If a field contains CRLF MySQL generates <escape>CRLF (the whole sequence is escaped only once). The file was created with this query:

{code}
SELECT * INTO OUTFILE '/mysql-export-line-terminated-by-crlf.csv' FIELDS TERMINATED BY ';' ESCAPED BY '\\' LINES TERMINATED BY '\r\n' FROM test
{code}

> Escaped line separators are not supported
> -----------------------------------------
>
>                 Key: CSV-35
>                 URL: https://issues.apache.org/jira/browse/CSV-35
>             Project: Commons CSV
>          Issue Type: Bug
>            Reporter: Emmanuel Bourg
>             Fix For: 1.0
>
>         Attachments: mysql-export-line-terminated-by-crlf.csv, mysql-export-line-terminated-by-lf.csv
>
>
> Commons CSV doesn't handle escaped line separators, for example:
> {code}
> value1;value2;value3a\
> value3b
> {code}
> In this case the expected result is:
> {code}["value1", "value2", "value3a\nvalue3b"]{code}
> This kind of escaping is produced by MySQL, whether the field enclosing is enabled or not. It's possible to see enclosing quotes and escaped line separators like this:
> {code}
> "value1";"value2";"value3a\
> value3b"
> {code}



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)