close2 / csv

A dart csv to list codec / converter
MIT License
98 stars 24 forks source link

[bug] `CsvToListConverter` does not split last row element from the first element of the next row. #50

Closed bySabi closed 2 years ago

bySabi commented 2 years ago

Tested with this code:

import 'dart:io';
import 'dart:convert' show utf8;
import 'package:csv/csv.dart';

final csvFilePath = './addresses.csv';

void main(List<String> arguments) async {
  final input = File(csvFilePath).openRead();
  final raw = await input
      .transform(utf8.decoder)
      .transform(CsvToListConverter())
      .toList();
  print(raw);
}

and this dataset: "addresses.csv"

John,Doe,120 jefferson st.,Riverside, NJ, 08075
Jack,McGinnis,220 hobo Av.,Phila, PA,09119
"John ""Da Man""",Repici,120 Jefferson St.,Riverside, NJ,08075

In the console output you can see that "08075 Jack" are the same element in the resulting List

[[John, Doe, 120 jefferson st., Riverside,  NJ,  08075
Jack, McGinnis, 220 hobo Av., Phila,  PA, 09119
John Da Man, Repici, 120 Jefferson St., Riverside,  NJ, 8075]]

And the same as in the issue https://github.com/close2/csv/issues/49. All rows are a single element of the resulting List

bySabi commented 2 years ago

Solved using CsvToListConverter(eol: "\n")