mapRow method
Maps a single raw CSV row into a typed map according to this mapping.
Implementation
Map<String, dynamic> mapRow({
required List<TCsvColumn> expectedColumns,
required List<String> csvHeaders,
required List<String> csvRow,
}) {
final rowMap = <String, dynamic>{};
for (final col in expectedColumns) {
final mappedHeader = mapping[col.key];
if (mappedHeader != null && mappedHeader.isNotEmpty) {
final headerIndex = csvHeaders.indexOf(mappedHeader);
if (headerIndex >= 0 && headerIndex < csvRow.length) {
final rawCell = csvRow[headerIndex];
rowMap[col.key] = col.parseValue(rawCell);
continue;
}
}
rowMap[col.key] = col.defaultValue;
}
return rowMap;
}