TCsvParser class

Robust parser and generator for CSV, TSV, Semicolon, Pipe, and JSON data.

Compliant with RFC-4180, supporting:

  • Quoted cells with commas, semicolons, tabs, pipes, and escaped quotes ("").
  • Multiline quoted cells.
  • Auto-detection of delimiters (,, ;, \t, |).
  • Auto-detection of JSON payload vs delimited tabular text.
  • Byte Order Mark (BOM) stripping.
  • Export & Template generation in CSV, TSV, Semicolon, Pipe, and JSON formats.

Constructors

TCsvParser()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

detectDelimiter(String content) → String
Auto-detects the most likely delimiter from CSV / TSV / DSV content.
detectFormat(String content) → TCsvFileFormat
Auto-detects the data format (JSON, TSV, Semicolon, Pipe, CSV) from content.
formatOutput(List<Map<String, dynamic>> maps, {TCsvFileFormat format = TCsvFileFormat.csv, List<TCsvColumn>? columns, String? delimiter, bool prettyJson = true}) → String
Formats and exports data according to the target TCsvFileFormat or custom delimiter.
generateTemplate(List<TCsvColumn> columns, {bool includeSampleRow = true, String delimiter = ',', TCsvFileFormat format = TCsvFileFormat.csv}) → String
Generates a sample template string based on a list of TCsvColumns in any format.
isJson(String content) → bool
Checks whether a text string contains valid JSON data (Array or Object).
parse(String content, {String? delimiter}) → List<List<String>>
Parses CSV / TSV / DSV / JSON text content into a list of row cells: List<List<String>>. Row 0 is headers, remaining rows are data records.
parseDelimited(String content, {String? delimiter}) → List<List<String>>
Parses standard delimited text (CSV, TSV, Semicolon, Pipe) into row cells.
parseGeneric(String content, {String? delimiter}) → TCsvParseResult
Parses generic content (CSV, TSV, Semicolon, Pipe, or JSON) into a structured TCsvParseResult.
parseJson(String content) → List<Map<String, dynamic>>
Parses JSON string content into a list of typed maps: List<Map<String, dynamic>>.
parseToMaps(String content, {List<TCsvColumn>? columns, String? delimiter}) → List<Map<String, dynamic>>
Parses any supported format (CSV, TSV, DSV, JSON) directly into typed Maps. If columns schema is provided, applies auto-mapping and type coercion.
toCsv(List<String> headers, List<List> rows, {String delimiter = ','}) → String
Converts headers and rows to a standard CSV formatted string with custom delimiter.
toCsvFromMaps(List<Map<String, dynamic>> maps, {List<TCsvColumn>? columns, List<String>? headers, String delimiter = ','}) → String
Converts a list of Maps to a CSV / TSV / DSV formatted string with custom delimiter.
toJson(List<Map<String, dynamic>> maps, {bool pretty = true}) → String
Converts a list of row maps to a formatted JSON string.
toJsonFromRows(List<String> headers, List<List> rows, {bool pretty = true, List<TCsvColumn>? columns}) → String
Converts headers and rows to a formatted JSON string.
toPipe(List<String> headers, List<List> rows) → String
Shortcut helper to export to Pipe-Separated Values (|).
toPipeFromMaps(List<Map<String, dynamic>> maps, {List<TCsvColumn>? columns, List<String>? headers}) → String
Shortcut helper to export to Pipe-Separated Values from maps.
toSemicolon(List<String> headers, List<List> rows) → String
Shortcut helper to export to Semicolon-Separated Values (;).
toSemicolonFromMaps(List<Map<String, dynamic>> maps, {List<TCsvColumn>? columns, List<String>? headers}) → String
Shortcut helper to export to Semicolon-Separated Values from maps.
toTsv(List<String> headers, List<List> rows) → String
Shortcut helper to export to Tab-Separated Values (TSV).
toTsvFromMaps(List<Map<String, dynamic>> maps, {List<TCsvColumn>? columns, List<String>? headers}) → String
Shortcut helper to export to TSV from maps.