[CSVUtil] double quotes

[CSVUtil] double quotes

Forge Component
Published on 2017-10-09 by Wei Zhu
21 votes
Published on 2017-10-09 by Wei Zhu
I need double quotes on only a few text fields.  Not all fields. Anyone know a way to selectively add quotes to fields?  When I have double quotes in the data, they are removed.  Any help is appreciated. Thanks.
Hi John

Double quote is used to enclose field that contains CR, LF, comma and double quote itself.
So if you need double quote, enclose that field with double quote and escape double quote in field with two double quotes.
For example , if your data is ab"cd, then in your CSV, that field  should be "ab""cd".

Thanks for the reply, but it doesn't work for me.  All I want is the double quotes around the field.  So if field1,"field2",field3 then field2 should output with double quotes, not the rest. It seems to be all or nothing. If the double quote is in the field, your solution works, but not if surrounding the field.

The default setting use double quote to enclose and escape which is compatiable with Excel and RFC4180. 
At this case, your data should be field1,"""field2""",field3.

But if there is no CR/LF/comma in field, you can use following solution to disable double quote
1. When import data from CSV, set IsDisableDoubleQuote of CSVLoadConfig to true.
2. When export data to CSV, set EncodeMode of CSVExportConfig to "noquote_nocheck".