Menu

#88 Only quote columns when separator is present in string

closed
None
3
2017-12-04
2017-09-04
Eric Weiser
No

Hi there,

Started using opencsv for a project this past week, thanks for your work.

When writing a CSV, I would like to be able to only quote a column when it contains the separator char, but looks like it's all (quote every column no matter what) or nothing (use CsvWriter.NO_QUOTE_CHARACTER).

e.g., current behavior is either:
"foo","bar","this one, has a comma" // unnecessary quoting
foo, bar, this one, has a comma // invalid, it should quote the last column.

i would like:
foo,bar,"this one, has a comma".

Happy to submit a feature request if you'd like.

SIDE NOTE: I see you've committed some bugfixes for 4.0 that I'd like to begin using (Namely, CsvToBean being Iterable<T> instead of Iterably); know when you'll be updating maven next?

Thanks again and happy labor day!
Eric

Discussion

  • Andrew Rucker Jones

    • assigned_to: Scott Conway
     
  • Andrew Rucker Jones

    Scott, you're more the parsing guru. Would you take this one?

     
  • Scott Conway

    Scott Conway - 2017-09-09

    What are you passing into the writeNext or writeAll? The java docs are at (http://opencsv.sourceforge.net/apidocs/com/opencsv/CSVWriter.html) and there you will see most of the write methods have an applyQuotesToAll parameter where if false should do what you want (and those that do not default to true).

    Right now 4.1 is looking to be somewhere around October. There is a feature I am trying to add and I am about a third of the way done but the next couple of weekends are going to be taken with home renovations.

    Let me know if the apply quotes to all does not work for you.

    Scott :)

     
  • Scott Conway

    Scott Conway - 2017-12-04
    • status: open --> closed
     
  • Scott Conway

    Scott Conway - 2017-12-04

    closed for no response.

     

Log in to post a comment.