CsvOpts Enumeration

Named constants to specify options for reading CSV files. The flags can be combined.

Definition

Namespace: FolkerKinzel.CsvTools
Assembly: FolkerKinzel.CsvTools (in FolkerKinzel.CsvTools.dll) Version: 2.0.1+2345335399184346d9b2cc992ed5c814406052c1
C#
[FlagsAttribute]
public enum CsvOpts

Remarks

  Tip

To work safely and conveniently with the CsvOpts enum, use the extension methods of the CsvOptsExtension class (see example).

Members

None0No flag is set. This creates a very lenient parser that rarely throws exceptions.
ThrowOnTooMuchFields1If set, CsvReader throws an CsvFormatException if a data row contains more fields than the first data row.

  Note

If a data row has more Fields than the first data row, this is a strong indication of a read error. The flag should therefore usually be set.

Unset this flag only if the CSV file has a header and if you are not interested in the surplus fields. Alternatively use OpenReadAnalyzed(String, Encoding, Header, Boolean, Int32) with MaxValue for the number of rows to analyze.

ThrowOnTooFewFields2 If set, CsvReader throws a CsvFormatException if a data row contains fewer fields than the first data row.

  Note

Other software may not mark empty fields at the end of the line with field separators. However, the absence of fields at the end of the line can also be an indication of a data error.
ThrowOnEmptyLines4If set, CsvReader throws an CsvFormatException if there are blank lines in the CSV file that are not part of a data field masked with quotes.

  Note

Blank lines that are not part of a masked field can in no case be interpreted as part of the data to be read. However, by removing the flag, CsvReader ignores such blank lines.
ThrowOnTruncatedFiles8If set, CsvReader throws an CsvFormatException if a masked field at the end of the file is not properly closed.

  Note

An unclosed masked field at the end of a CSV file is a data error. However, by removing the flag, CsvReader will be able to parse the rest of the file. The ThrowOnTooFewFields flag should also be unset in this case because a CSV row could be truncated by the unclosed masked field.
Default15Default setting. This is a combined value, that forces CsvReader to throw an CsvFormatException if the file to be read does not comply with the RFC 4180 standard. (Alternative column separators and newline characters are always tolerated.)
CaseSensitiveKeys16If the flag is not set, the class CsvRecord interpretes the column names of the CSV file in a case-insensitive manner. This is the same behavior that DataColumnCollection shows.
TrimColumns32If the flag is set, CsvReader will remove leading and trailing white space from all data tokens and the column names. That can damage data where the white space has a meaning. Only set the flag for reading non-standard CSV files, that introduce additional padding.
DisableCaching64Set this flag to gain performance benefits when parsing large files. Note that if this flag is set, the results of the read operation cannot be cached: the CsvRecord instance provided by CsvReader will then always be the same. Only the values ​​it contains will update with each iteration.

See Also