CsvAnalyzerAnalyzeString Method

Analyzes a String that contains CSV data to get the appropriate method arguments for parsing.

Definition

Namespace: FolkerKinzel.CsvTools
Assembly: FolkerKinzel.CsvTools (in FolkerKinzel.CsvTools.dll) Version: 2.0.1+2345335399184346d9b2cc992ed5c814406052c1
C#
public static CsvAnalyzerResult AnalyzeString(
	string csv,
	Header header = Header.ProbablyPresent,
	int analyzedLines = 5
)

Parameters

csv  String
The CSV-String to analyze.
header  Header  (Optional)
A supposition that is made about the presence of a header row.
analyzedLines  Int32  (Optional)
Maximum number of lines to analyze in csv. The minimum value is AnalyzedLinesMinCount. If csv has fewer lines than analyzedLines, it will be analyzed completely. (You can specify Int32.MaxValue to analyze the entire String in any case.)

Return Value

CsvAnalyzerResult
The results of the analysis.

Remarks

CsvAnalyzer performs a statistical analysis on the String. The result of the analysis is therefore always only an estimate, the accuracy of which increases with the number of lines analyzed.

The field delimiters COMMA (',', %x2C), SEMICOLON (';', %x3B), HASH ('#', %x23), TAB ('\t', %x09), and SPACE (' ', %x20) are recognized automatically.

Exceptions

ArgumentNullExceptioncsv is null.
ArgumentOutOfRangeException

header is not a defined value of the Header enum.

- or -

header is a combination of Header values.

See Also