Fields in CSV files can be enclosed in quotes.
Although the CSV specification requires quotes only when a field contains a separator, delimiter,
or enclosure character, some applications may always enclose fields in quotes for consistency or simplicity.
From a specification standpoint, these two examples are data identical:
However, certain use cases may require enclosing fields to convey a different meaning.
For example, this can help distinguish between fields containing an empty string and those with no value at all
(null fields).
FastCSV addresses this need by offering various quote strategies.
You may also check the corresponding
Javadoc
for more information.
Writing fields with different quote strategies
In the following example, CSV output is created using different quote strategies.
To determine if a field is enclosed in quotes when reading a CSV file,
additional work and an extra object per field are required.
FastCSV does not support this feature out of the box, but it can be implemented using a custom callback handler.