Csv Reader / deserializer tools
- Header, array of strings with header names, default is null
- HasHeaderRow, indicates that the first row is a header and becomes the Header option not set, default is false
- Delimiter, cell delimiter char, default is ',';
- KeepEnclosureQuotes, indicates whether to keep cell enclosure quotes, default is false
- Explicit, explicit line checking compares header cell count to line cell count, default is false
- IgnoreEmptyWhenDeserializing, indicates that empty cells should not be used as values when deserializing, default is false
using TextReader reader = File.OpenText(filePath);
var csvReader = new CsvReader(reader);
csvReader.Options.Header = csvReader.ReadLine();
while(!csvReader.EndOfStream)
{
string? line = csvReader.ReadLine();
ProcessCsvLine(line, csvReader.CurrentLineNumber);
}
using TextReader reader = File.OpenText(filePath);
var csvReader = new CsvReader<Poco>(reader);
csvReader.Options.Header = csvReader.ReadLine();
while(!csvReader.EndOfStream)
{
Poco? item = csvReader.ReadObject();
ProcessObject(item, csvReader.CurrentLineNumber);
}
csv specs rfc4180