parse method

(List<Map<String, String>>, {List<String> columns}) parse(
  1. String data
)

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.

Unlike parseRows, this method requires that the first line of the DSV content contains a delimiter-separated list of column names; these column names become the keys on the returned maps. For example, consider the following CSV file:

Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38

The resulting Dart list is:

[
  {"Year": "1997", "Make": "Ford", "Model": "E350", "Length": "2.34"},
  {"Year": "2000", "Make": "Mercury", "Model": "Cougar", "Length": "2.38"}
];

The returned record also exposes a columns field containing the column names in input order. For example:

data.columns; // ["Year", "Make", "Model", "Length"]

If the column names are not unique, only the last value is returned for each name; to access all values, use parseRows instead (see example).

There is no automatic conversion to numbers, dates, or other types. To convert the maps during the parse process, use parseWith.

Implementation

(List<Map<String, String>>, {List<String> columns}) parse(String data) =>
    parseWith<Map<String, String>>(data, (d, _, __) => d);