Are there any CSV readers/writer libraries in C#?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Yes - though I assume you're actually asking for specifics?
Try FileHelpers
Try CsvHelper. It's as easy to use as FastCsvReader and does writing also. I've been very happy with FastCsvReader in the past, but I needed something that does writing also, and wasn't happy with FileHelpers.
Reading:
Writing:
Full Disclosure: I am the author of this library.
There are dozens.
http://www.filehelpers.net/ is one of the most common.
I should say that I find Filehelpers restrictive in some scenarios, and instead use The Fast CSV Reader. In my experience, if you dont know the format of your CSV file or import mapping until runtime - this is the better library to use.
Sebastien Lorion has a great
CSV
reader on CodeProject called A Fast CSV Reader. Probably one of the best for C# and it's free.As far as writing, just use
StreamWriter
.Here is some boilerplate code for writing a
DataGridView
to a file:There are a couple of options, right in the framework itself.
One of the easiest is to Reference Microsoft.VisualBasic, then use TextFieldParser. It is a fully functional CSV reader in the core framework.
Another good alternative is to use datasets to read CSV files.