DsvFormat class

A class for parsing and formatting Delimiter-Separated Values (DSV) data.

This class provides methods for parsing and formatting DSV data, which is a common format for representing tabular data where values are separated by a specified delimiter character (e.g., comma, semicolon, tab).

Example usage:

final csv = DsvFormat(",");
final data = "Name,Age,Country\nAlice,28,USA\nBob,22,Canada";

final parsedData = csv.parse(data);
print(parsedData);

final formattedData = csv.format(parsedData);
print(formattedData);

Constructors

DsvFormat(String delimiter)
Constructs a new DSV parser and formatter for the specified delimiter.

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

format(Iterable<Map<String, Object?>> rows, [Iterable<String>? columns]) String
Formats the specified iterable of map rows as delimiter-separated values, returning a string.
formatBody(Iterable<Map<String, Object?>> rows, [Iterable<String>? columns]) String
Equivalent to format, but omits the header row.
formatRow(Iterable<Object?> row) String
Formats a single iterable row of strings as delimiter-separated values, returning a string.
formatRows(Iterable<Iterable<Object?>> rows) String
Formats the specified iterable of iterable of string rows as delimiter-separated values, returning a string.
formatValue(Object? value) String
Format a single value or string as a delimiter-separated value, returning a string.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
parse(String data) → (List<Map<String, String>>, {List<String> columns})
Parses the specified data, which must be in the delimiter-separated values format with the appropriate delimiter, returning an list of maps representing the parsed rows.
parseRows(String data) List<List<String>>
Parses the specified data, which must be in the delimiter-separated values format with the appropriate delimiter, returning an list of lists representing the parsed rows.
parseRowsWith<R>(String text, R? conversion(List<String>, int)) List<R>
Similar to parseRows, but applies the specified conversion function to each row.
parseWith<R>(String text, R? conversion(Map<String, String>, int, List<String>)) → (List<R>, {List<String> columns})
Similar to parse, but applies the specified conversion function to each row.
toString() String
A string representation of this object.
inherited

Operators

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