I\'m working on a project and I need to read a CSV file and then fill a DataSet with its data. I\'ve been searching and I have found some interesting things in OleDB.
I always use this CSV library for reading CSV files in through C# its always worked good for me.
http://www.codeproject.com/KB/database/CsvReader.aspx
Heres an example of reading a CSF file using the library
using System.IO;
using LumenWorks.Framework.IO.Csv;
void ReadCsv()
{
// open the file "data.csv" which is a CSV file with headers
using (CsvReader csv =
new CsvReader(new StreamReader("data.csv"), true))
{
int fieldCount = csv.FieldCount;
string[] headers = csv.GetFieldHeaders();
while (csv.ReadNextRecord())
{
for (int i = 0; i < fieldCount; i++)
Console.Write(string.Format("{0} = {1};",
headers[i], csv[i]));
Console.WriteLine();
}
}
}