Closed tantzygames closed 1 year ago
Are you trying to parse the same csv file?
My first guess would be that the End Of Line character is different.
Try the FirstOccurenceSettingsDetector
:
var d = new FirstOccurrenceSettingsDetector(eols: ['\r\n', '\n']);
String codetxt = await rootBundle.loadString('assets/file.csv');
List<List<dynamic>> codeList = CsvToListConverter(csvSettingsDetector: d).convert(codetxt);
print('codelist size ' + codeList.length.toString());
Yes, it's the same file, but your suggestion worked. Thanks!
I'm compiling Android on Windows and iOS on Mac. The file has \r\n line endings, but maybe mac is ignoring the \r which was causing the problem?
PS Thanks so much for this package. CSV is 600k, equivalent json is over 2Mb and slow to load on iOS.
This problem started after upgrading flutter. One has to specify this way explicitly. On my side, it worked well before the update, but after going to flutter 1.9.1 from flutter 1.7.8, i had to explicitly specify var d = new FirstOccurrenceSettingsDetector(eols: ['\r\n', '\n']);
Are you trying to parse the same csv file?
My first guess would be that the End Of Line character is different.
Try the
FirstOccurenceSettingsDetector
:var d = new FirstOccurrenceSettingsDetector(eols: ['\r\n', '\n']); String codetxt = await rootBundle.loadString('assets/file.csv'); List<List<dynamic>> codeList = CsvToListConverter(csvSettingsDetector: d).convert(codetxt); print('codelist size ' + codeList.length.toString());
I had to import a specific file from the csv-library in order to access FirstOccurenceSettingsDetector:
import 'package:csv/csv_settings_autodetection.dart' as csvAuto;
var d = new csvAuto.FirstOccurrenceSettingsDetector(eols: ['\r\n', '\n']);
Are you trying to parse the same csv file?
My first guess would be that the End Of Line character is different.
Try the
FirstOccurenceSettingsDetector
:var d = new FirstOccurrenceSettingsDetector(eols: ['\r\n', '\n']); String codetxt = await rootBundle.loadString('assets/file.csv'); List<List<dynamic>> codeList = CsvToListConverter(csvSettingsDetector: d).convert(codetxt); print('codelist size ' + codeList.length.toString());
Thank you, it worked for me too. Flutter version 1.20.1
and csv: ^4.0.3
I ran the code on my Windows PC giving my Android virtual and real device a working file, but when deployed via Play Store it didn't work. This finally made me realize it's just a compiletime issue. My app is built on a Linux device. This issue should be closed, as it is not really an issue :)
Thanks for the feedback!
using csv: ^4.0.3
I have successfully converted a csv file on Andoid, but the same code doesn't work on iOS.
This results in 66k entries for Android, but only 1 for iOS.
I've checked that the csv is loading properly on iOS. I'm not sure what else I should be looking for to track down the cause?