public static (CsvAnalyzerResult AnalyzerResult, Encoding Encoding) AnalyzeFile(
string filePath,
Encoding? defaultEncoding = null,
Header header = Header.ProbablyPresent,
int analyzedLines = 5
)
Public Shared Function AnalyzeFile (
filePath As String,
Optional defaultEncoding As Encoding = Nothing,
Optional header As Header = Header.ProbablyPresent,
Optional analyzedLines As Integer = 5
) As (AnalyzerResult As CsvAnalyzerResult, Encoding As Encoding)
public:
static ValueTuple<CsvAnalyzerResult^, Encoding^> AnalyzeFile(
String^ filePath,
Encoding^ defaultEncoding = nullptr,
Header header = Header::ProbablyPresent,
int analyzedLines = 5
)
static member AnalyzeFile :
filePath : string *
?defaultEncoding : Encoding *
?header : Header *
?analyzedLines : int
(* Defaults:
let _defaultEncoding = defaultArg defaultEncoding null
let _header = defaultArg header Header.ProbablyPresent
let _analyzedLines = defaultArg analyzedLines 5
*)
-> ValueTuple<CsvAnalyzerResult, Encoding>
The method performs a statistical analysis on the CSV file to find the appropriate parameters for reading the file. The result of the analysis is therefore always only an estimate, the accuracy of which increases with the number of lines analyzed. The analysis is time-consuming because the CSV file has to be accessed for reading.
The field delimiters COMMA (',', %x2C), SEMICOLON (';', %x3B), HASH ('#', %x23), TAB ('\t', %x09), and SPACE (' ', %x20) are recognized automatically.
This method also tries to determine the Encoding of the CSV file from the byte order mark (BOM). If no byte order mark can be found, defaultEncoding is used.
ArgumentNullException | filePath is null. |
ArgumentOutOfRangeException | header is not a defined value of the Header enum. - or - header is a combination of Header values. |
ArgumentException | filePath is not a valid file path. |
IOException | I/O error. |