I have a big CSV file (200 MB)
ID,Item,Description
1,TV,"Excellent condition, no marks, and brand new"
2,PC, "Used, missing keyboard"
....
I need to put it into a datatable so then in my C# Windows Forms application I can build a TreeView and GridView.
I found many examples to do so..
One approach is using System.IO
using System.IO.File;
return ReadAllLines(@"C:\MyFile.csv").Select(line => line.Split(',')).ToList();
and the other approach is using GenericParsing
var adapter = new GenericParsing.GenericParserAdapter(path);
DataTable dt = adapter.GetDataTable();
Approach 1 has a problem is that it split columns by delimeter ","
This is a problem because in my file comma can appear in the same column as a char not as delimeter
The 2nd approach required high memory and failing due to this error
This exception was originally thrown at this call stack: [External Code] Encoder.FrmCoder.GetDataTableFromCsv(string, bool) in FrmCoder.cs Encoder.FrmCoder.FrmCoder_Load(object, System.EventArgs) in FrmCoder.cs [External Code]
Any other approach can load big file easily without issues?