CsvLoader class
CsvLoader wraps around a Stream and enables reading data in CSV format. Consumers of CSV data can use the rows stream to receive each line as a CsvData object.
Example:
var csv = CsvLoader.withHeaders(myStream);`
await for (var row in csv.rows) {
// do something with the row
}
Constructors
-
CsvLoader(Stream<
String> stream, {String separator = _defSeparator, String endOfLine = _defEndOfLine}) -
Builds a new CsvLoader bound to
stream
.separator
(default is','
) andendOfLine
(default is'\r\n'
) can be overriden. Using this constructor, data can only be read by index. -
CsvLoader.withHeaders(Stream<
String> stream, {Encoding encoding = utf8, String separator = _defSeparator, String endOfLine = _defEndOfLine}) -
Builds a new CsvLoader bound to
stream
. The first non-empty line from the CSV data source will be used to populate the CsvData.headers; headers are not provided in the rows stream.separator
(default is','
) andendOfLine
(default is'\r\n'
) can be overriden. Using this constructor, data may be read by header name and/or index.
Properties
- endOfLine → String
-
End-of-line character; default is
'\r\n'
.final - hashCode → int
-
The hash code for this object.
no setterinherited
- hasHeaders → bool
-
true
if this instance was constructed with CsvLoader.withHeaders.final -
headers
→ Iterable<
String> -
List of headers found in the first non-empty line of the CSV data source. This list is populated
if the reader was constructed with CsvLoader.withHeaders; otherwise it is empty.
no setter
-
rows
→ Stream<
CsvData> -
Stream of CsvData; empty rows from the CSV data source are ignored.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- separator → String
-
Separator character; default is
','
.final
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