Extract row data from csv file. Flutter

Viewed 129

I'm having a file containing multiple data in different rows, where in the first row is having some of the ANSI values and the other rows is having UTF-8 related values.

I was hoping to extract only the first row and decode the ANSI value with the help of the ascii.decoder and in the other rows with the help of utf-8.decoder.

I successfully did the decode when i removed the first row from the csv file manually and vice versa but how to do that programmatically?

This is csv file

This is what I'm trying to do

final ackFile = File(entities[i].path).openRead(); //To read the file
final ackFields = await ackFile.transform(utf8.decoder).transform(const CsvToListConverter()).toList(); //To extract it I'm getting error
//also here
final ackFile = File(entities[i].path).openRead().transform(utf8.decoder).transform(LineSplitter()).forEach((element) => print("Element is $element")); //When trying to read the csv file line by line

I'm getting an error stating as

I/flutter (22362): The supplied value (512.000000pt) will be discarded and treated as if it had not been specified.
E/flutter (22362): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: Unexpected extension byte (at offset 82)
E/flutter (22362): #0      _Utf8Decoder.convertChunked (dart:convert-patch/convert_patch.dart:1893:7)
E/flutter (22362): #1      _Utf8ConversionSink.addSlice (dart:convert/string_conversion.dart:314:28)
E/flutter (22362): #2      _Utf8ConversionSink.add (dart:convert/string_conversion.dart:310:5)
E/flutter (22362): #3      _ConverterStreamEventSink.add (dart:convert/chunked_conversion.dart:72:18)
E/flutter (22362): #4      _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
E/flutter (22362): #5      _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (22362): #6      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (22362): #7      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
E/flutter (22362): #8      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (22362): #9      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
E/flutter (22362): #10     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:733:19)
E/flutter (22362): #11     _StreamController._add (dart:async/stream_controller.dart:607:7)
E/flutter (22362): #12     _StreamController.add (dart:async/stream_controller.dart:554:5)
E/flutter (22362): #13     _FileStream._readBlock.<anonymous closure> (dart:io/file_impl.dart:98:19)
E/flutter (22362): #14     _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (22362): #15     _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (22362): <asynchronous suspension>
E/flutter (22362): 
0 Answers
Related