CsvConverterParseAnalyzedTResult(String, CsvToTResult, Header, Int32) Method

Parses a CSV-String after it had been analyzed.

Definition

Namespace: FolkerKinzel.CsvTools.Mappings
Assembly: FolkerKinzel.CsvTools.Mappings (in FolkerKinzel.CsvTools.Mappings.dll) Version: 1.1.0+1263e8243dc2cd78095f678f813d7d9c52ea4315
C#
public static TResult[] ParseAnalyzed<TResult>(
	string csv,
	CsvTo<TResult> converter,
	Header header = Header.ProbablyPresent,
	int analyzedLines = 5
)

Parameters

csv  String
The CSV-String to parse.
converter  CsvToTResult
An object that converts a CSV row to a TResult instance.
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.)

Type Parameters

TResult
Generic type parameter that specifies the Type of the items in the array that the method returns.

Return Value

TResult
An array of TResult instances, initialized from the parsed csv.

Remarks

CsvAnalyzer performs a statistical analysis on csv. 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, or converter is null.
ArgumentOutOfRangeException

header is not a defined value of the Header enum.

- or -

header is a combination of Header values.

CsvFormatExceptionInvalid CSV file. Try to increase the value of analyzedLines to get a better analyzer result!
FormatException Parsing fails and Throwing is true.

See Also