csv icon indicating copy to clipboard operation
csv copied to clipboard

svToListConverter().convert doesn`t work on IOS (works on android)

Open echogit opened this issue 2 years ago • 3 comments

I have a csv on this format with 28 lines:

id,name,image
familia,Família,familia.jpg
minhafamilia,Minha Família,minha-familia.jpg
escola,Escola,escola.jpg
sentimentos,Sentimentos,sentimentos.jpg

On android it creates a list of 28 itens, each one with 3 itens, just as the csv.

On IOs it creates a list of 61 itens, ignoring the first field and adding the 2nd and 3rd field on a sequence. Weird. I`m 3 hours here trying to find out what the problem was.

my code:

     final String categoriesCsvContent = await rootBundle.loadString('assets/csvs/$categoriesCsvFileName');
    _categoriesCsvData = CsvToListConverter().convert(categoriesCsvContent);

I got the problem just now, it is the eol, so I just changed like this:

    categoriesCsvContent = await rootBundle.loadString('assets/csvs/$categoriesCsvFileName');
    categoriesCsvContent = categoriesCsvContent.replaceAll('\n','\r\n');

But it would be nice if the code could treat this automatically.

echogit avatar Nov 29 '23 01:11 echogit

came here to make this post, it works fine on Android but not on IOS

hedihadi avatar Oct 30 '24 18:10 hedihadi

@hedihadi Could you please confirm, that you are using the same file.

If yes, did you try to adjust the EOL as mentioned in the first comment?

close2 avatar Oct 31 '24 07:10 close2

@hedihadi What happens if you use:

var d = FirstOccurrenceSettingsDetector(eols: ['\r\n', '\n'],
                                            textDelimiters: ['"', "'"]);

CsvToListConverter(csvSettingsDetector: d);

?

close2 avatar Oct 31 '24 07:10 close2