Menu

#83 it should be allowed that quote are escape the same

v1.0 (example)
closed-out-of-date
nobody
None
5
2016-04-27
2011-11-02
Anonymous
No

This is a follow up to: "quote char is ignored when quote char=escape char - ID: 3030747"

It is now forbidden for CSVReader that the quote and escape character are the same. if the two are the same it throws:
"The separator, quote, and escape characters must be different!"

However http://tools.ietf.org/html/rfc4180 recommends that doublequotes within a doublequote enclosed field should be escaped by another doublequote.

In my case, I should process CSV files created by Excel. Excel does exactly this. It encloses fields in double quotes. It escapes doublequotes with a 2nd doublequote. So CSVReader can not properly process MS Excel CSV-Files.

Discussion

  • Anonymous

    Anonymous - 2012-02-14

    Note also that the default CSVWriter has the quote and escape characters the same, being a double-quote. So, OpenCSV can write CSV files which it cannot read.

     
  • rborchert

    rborchert - 2012-02-14

    Actually, it works fine, just not the way you think. Its defaults are comma for separator, quote for the quote character, and backslash for the escape character. However, it understands two consecutive quote characters as an escaped quote character. So, if you just go with the defaults, it will work fine. I use it to read CSV files from Excel all the time, including with double double quotes.

     
    • Jan Gargulák

      Jan Gargulák - 2018-02-19

      Not true that it "works fine".
      You say backslash for the escape. But what happens when backslash appears in the data? Your reader will consider it to be an escape character, but it is NOT - it's just a regular data character.
      This would deserve reopen and proper fix.

       
      • Scott Conway

        Scott Conway - 2018-03-04

        Yay - sourceforge is back! I can respond!!

        Jan if you are using the CSVParser and you want the escape character as data then you just need to escape it with the escape character (so your would have two slashes instead of one). You can write a simple junit test sending output to the CSVWriter to see that in action or look at the issue123SeparatorEscapedWhenQuoteIsNoQuoteChar method in the CSVWriterTest.

         
  • bbabic

    bbabic - 2013-08-30

    JFTR, 2 and half years later, the same "bug" still exists.

     
  • Andrew Rucker Jones

    • status: open --> closed-out-of-date
    • Group: --> v1.0 (example)
     
  • Andrew Rucker Jones

    Cleaning up old issues. If this still needs attention, please open a new ticket.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.