convertLines method
Parses given CSV lines
multiline
can be used to control if a single row can span multiple lines
Implementation
List<List<String>> convertLines(Iterable<String> lines, {bool? multiline}) {
final bool isMultiline = multiline ?? this.multiline;
final List<List<String>> ret = [];
String? previousLine;
for (String line in lines) {
if (previousLine == null) {
final List<String>? row = parseRow(line, fs: fieldSep, ts: textSep);
if (row != null) {
ret.add(row);
} else {
if (!isMultiline) {
throw Exception('Invalid row!');
}
previousLine = line;
}
} else {
previousLine = previousLine + '\r\n' + line;
final List<String>? row =
parseRow(previousLine, fs: fieldSep, ts: textSep);
if (row != null) {
ret.add(row);
previousLine = null;
}
}
}
return ret;
}