You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jurrie Overgoor (JIRA)" <ji...@apache.org> on 2018/10/07 20:33:00 UTC

[jira] [Comment Edited] (CSV-208) Cannot parse PostgreSQL CSV and Text formats

    [ https://issues.apache.org/jira/browse/CSV-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16641162#comment-16641162 ] 

Jurrie Overgoor edited comment on CSV-208 at 10/7/18 8:32 PM:
--------------------------------------------------------------

I'm running into the same issue.
I'm now using the the following format:
{code:java}
CSVFormat.POSTGRESQL_CSV.withEscape('\\');
{code}
It seems to work ok.

So the bug is in the defautl formatters. I [submitted a simple PR|https://github.com/apache/commons-csv/pull/32], but integration tests seem to fail for reasons unclear to me.

But it exposes another issue: you can assign the quote and the escape character the same character. This is not supported. So either you should get an IllegalArgumentException, or it should be supported by commons-csv I feel.


was (Author: jurrieovergoor):
I'm running into the same issue.
I'm now using the the following format:
{code:java}
CSVFormat.POSTGRESQL_CSV.withEscape('\\');
{code}
It seems to work ok.

So the bug is in the defautl formatters. But it exposes another issue: you can assign the quote and the escape character the same character. This is not supported. So either you should get an IllegalArgumentException, or it should be supported by commons-csv I feel.

> Cannot parse PostgreSQL CSV and Text formats
> --------------------------------------------
>
>                 Key: CSV-208
>                 URL: https://issues.apache.org/jira/browse/CSV-208
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>            Reporter: Gary Gregory
>            Priority: Major
>         Attachments: CSVFormatTest.java
>
>
> Cannot parse PostgreSQL CSV and Text formats.
> We cannot seem to parse the stock PostgreSQL Text format, see 
> - org.apache.commons.csv.CSVPrinterTest.testRandomPostgreSqlCsv()
> - org.apache.commons.csv.CSVPrinterTest.testRandomPostgreSqlText()
> - org.apache.commons.csv.CSVPrinterTest.testPostgreSqlCsvNullOutput()
> - org.apache.commons.csv.CSVPrinterTest.testPostgreSqlCsvTextOutput()
> I am guessing that the issue is that in PostgreSQL, the escape character is the same as the quote character:
> {quote}
> QUOTE
> Specifies the quoting character to be used when a data value is quoted. The default is double-quote. This must be a single one-byte character. This option is allowed only when using CSV format.
> ESCAPE
> Specifies the character that should appear before a data character that matches the QUOTE value. The default is the same as the QUOTE value (so that the quoting character is doubled if it appears in the data). This must be a single one-byte character. This option is allowed only when using CSV format.
> {quote}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)