it should be allowed that quote are escape the same
Brought to you by:
aruckerjones,
sconway
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.
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
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.
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.
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.
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.
JFTR, 2 and half years later, the same "bug" still exists.
Cleaning up old issues. If this still needs attention, please open a new ticket.