commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Eatwell (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CSV-200) CSVFormat cannot read its own output if input contain escape character followed by quote character
Date Mon, 24 Oct 2016 14:01:58 GMT

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

Vladimir Eatwell commented on CSV-200:
--------------------------------------

The workaround is to not quote and escape but just do one or the other.

> CSVFormat cannot read its own output if input contain escape character followed by quote
character
> --------------------------------------------------------------------------------------------------
>
>                 Key: CSV-200
>                 URL: https://issues.apache.org/jira/browse/CSV-200
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.4
>            Reporter: Vladimir Eatwell
>
> I can format CSV using CSVFormat that is subsequently unparsable by CSVFormat, the test
below illustrates the failure:
> {code}
> import org.apache.commons.csv.CSVFormat;
> import org.apache.commons.csv.CSVRecord;
> import org.apache.commons.csv.QuoteMode;
> import org.junit.Test;
> import java.io.StringReader;
> import java.util.List;
> public class CSVFormatTest {
>     @Test
>     public void parseFailure() throws Exception {
>         CSVFormat formatter = CSVFormat.DEFAULT;
>         formatter = formatter.withDelimiter(',');
>         formatter = formatter.withQuote('*');
>         formatter = formatter.withEscape('/');
>         formatter = formatter.withNullString("NULL");
>         formatter = formatter.withIgnoreSurroundingSpaces(true);
>         formatter = formatter.withQuoteMode(QuoteMode.MINIMAL);
>         String formatted = formatter.format("bob/*", "token");
>         List<CSVRecord> parsed = formatter.parse(new StringReader(formatted)).getRecords();
>         for (CSVRecord record : parsed) {
>             System.out.println(record.size());
>         }
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message