Reading csv file in DataTable using c #?

I have several Python scripts that I wrote some time ago to do some data processing. I need to โ€œportโ€ some of these scripts to C #.

Python provides a CSV module that makes it easy to import CSV data from a file into a dictionary. I want to have the same functionality in my library, but since I'm new to C #, I decided to come here to ask for a best practice method for importing CSV data into a DataTable.

Am I rolling back on my own or is there a CSV ala Python module?

+4
source share
2 answers

I would not roll back. You will have your work cut out, trying to deal with all the strange corner cases that CSV files can throw to you.

I would recommend the Sรฉbastien Lorion Fast CSV Reader :

using (var csv = new CachedCsvReader(new StreamReader(filePath), true)) { DataTable Table = new DataTable(); Table.Load(csv); } 
+9
source

I did not find the embedded .NET (this is when I encoded my solution in .NET 2.0) that met my needs, so I used the open source link below. I process about 36,000 files per month, it works well, and I still have a problem.

Csvreader

+1
source

All Articles