Question

I need a CSVParser class file A Class File which parses csv and returns a dataSet as a result ASP.Net

Was it helpful?

Solution

I'm pretty sure that CSVReader (CodeProject) can read to DataTable.

        DataTable table = new DataTable();
        // set up schema... (Columns.Add)
        using(TextReader text = File.OpenText(path))
        using(CsvReader csv = new CsvReader(text, hasHeaders)) {
            table.Load(csv);
        }

Note that manually setting up the schema is optional; if you don't, I believe it assumes that everything is string.

OTHER TIPS

Simple google gives plenty of results.

I've had luck with this parser. It will return results to a DataSet.

Another tool you might want to check out is FileHelpers. I see there's a tag for this resource here on SO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top