Class CsvAnalyzer
Inheritance
System.Object
CsvAnalyzer
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.IO.Csv
Assembly: Mars.IO.dll
Syntax
public static class CsvAnalyzer
Methods
| Improve this Doc View SourceAnalyze(Stream, Char[], Encoding, out Int32, out Char, out Encoding, out Int32, out Int32)
Reads completely through a CSV stream to determine encoding, separator, field count and row count.
Uses fallbackEncoding if there is no BOM. Throws DecoderFallbackException if there are invalid characters in the
stream.
Returns the separator whose average field count is closest to its max field count.
Declaration
public static void Analyze(Stream stream, char[] separators, Encoding fallbackEncoding, out int fieldCount, out char autodetectSeparator, out Encoding autodetectEncoding, out int bomLength, out int rowCount)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | |
System.Char[] | separators | |
System.Text.Encoding | fallbackEncoding | |
System.Int32 | fieldCount | |
System.Char | autodetectSeparator | |
System.Text.Encoding | autodetectEncoding | |
System.Int32 | bomLength | |
System.Int32 | rowCount |
Analyze(String, Char[], Encoding, out Int32, out Char, out Encoding, out Int32, out Int32)
Reads completely through a CSV input file to determine encoding, separator, field count and row count.
Uses fallbackEncoding if there is no BOM. Throws DecoderFallbackException if there are invalid characters in the
stream.
Returns the separator whose average field count is closest to its max field count.
Declaration
public static void Analyze(string file, char[] separators, Encoding fallbackEncoding, out int fieldCount, out char autodetectSeparator, out Encoding autodetectEncoding, out int bomLength, out int rowCount)
Parameters
Type | Name | Description |
---|---|---|
System.String | file | The input file csv file to analyze. |
System.Char[] | separators | Set of separators to look for. |
System.Text.Encoding | fallbackEncoding | Fallback encoding when default is not suitable. |
System.Int32 | fieldCount | Output value of identified count of fields in this table. |
System.Char | autodetectSeparator | Output value of identified value separator. |
System.Text.Encoding | autodetectEncoding | Output value of identified encoding. |
System.Int32 | bomLength | Output value of |
System.Int32 | rowCount |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |