Tiny CSV toolkit for .NET. Easy to read and write CSV table.
- Easy to read and write csv table.
- Custom header lines.
- Support choose new line style:
Environment | Unix | NonUnix |
---|---|---|
Environment.NewLine | \n | \r\n |
- Support cell's form:
contain cells separators | contain double quotes | custom cells separator | multiline |
---|---|---|---|
√ | √ | √ | √ |
- You can custom cells separator. Default is comma.
- You can choose whether to support multiline cells. Default is support.
More examples can be found in the TinyCSV.Example.
var csv = File.ReadAllText("sample.csv");
//Create csv reader form csv content, custom cell separator.
CSVTableReader csvTableReader = new CSVTableReader(csv, 2, ',');
//Create a empty csv writer.
CSVTableWriter csvTableWriter = new CSVTableWriter()
//Add headers.
.AddHeader(new CSVRecordWriter {"Data1", "Data2"})
.AddHeader(new CSVRecordWriter {"string", "int"})
//Add records.
.AddRecord(new CSVRecordWriter()
.Add("string with double quote\" and comma, and \n\\n and \r\n\\r\\n")
.Add("1"));
//Get csv form string, custom cell separator and choose new line style.
string csv = csvTableWriter.GetEncodeTable(',', NewLineStyle.NonUnix);
//Create csv writer from csv content.
CSVTableWriter csvTableWriter2 = new CSVTableWriter(csv, 2);
TinyCSV currently targets and supports
- .NET Framework 4.0 and above.