0 purchases
d4 dsv
A parser and formatter for delimiter-separated values, such as CSV and TSV.
These tabular formats are popular with spreadsheet programs such as
Microsoft Excel, and are often more space-efficient than JSON. This
implementation is based on
RFC 4180.
Comma (CSV) and tab (TSV) delimiters are built-in. For example, to parse:
csvParse("foo,bar\n1,2"); // ([{foo: 1, bar: 2}], columns: [foo, bar])
tsvParse("foo\tbar\n1\t2"); // ([{foo: 1, bar: 2}], columns: [foo, bar])
copied to clipboard
Or to format:
csvFormat([{"foo": "1", "bar": "2"}]); // "foo,bar\n1,2"
tsvFormat([{"foo": "1", "bar": "2"}]); // "foo\tbar\n1\t2"
copied to clipboard
To use a different delimiter, such as “|” for pipe-separated values, use
DsvFormat:
final psv = DsvFormat("|");
print(psv.parse("foo|bar\n1|2")); // ([{foo: 1, bar: 2}], columns: [foo, bar])
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.