Reading ambiguous data
There are a few widespread ambiguities in CSV files:
- Empty lines: CSV files can contain empty lines, which are lines that contain no data. See the Empty lines section of the CSV Interpretation page for more information.
- Empty fields: CSV files can contain empty fields, which are fields that contain no data. See the Empty fields / null values section of the CSV Interpretation page for more information.
- Missing fields: CSV files can contain missing fields, which are fields that are not present in a record. See the Different field count of the CSV Interpretation page for more information.
FastCSV is very aware of these ambiguities and provides ways to handle them.
Many other ambiguities can occur in CSV files. The JavaCsvComparison project provides a comparison of different CSV libraries and how they handle these ambiguities.
Example
In the following example, a CSV file with various ambiguous data is read using FastCSV.
You also find this source code example in the FastCSV GitHub repository.