Howto parse csv and returns a dataSet as a result

2019-08-30 22:00发布

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

3条回答
姐就是有狂的资本
2楼-- · 2019-08-30 22:42

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.

查看更多
干净又极端
3楼-- · 2019-08-30 23:03

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.

查看更多
霸刀☆藐视天下
4楼-- · 2019-08-30 23:04

Simple google gives plenty of results.

查看更多
登录 后发表回答