Skip to content
/ TinyCSV Public

Tiny CSV toolkit for .NET. Easy to read and write CSV table. Support cells contain comma and double quote characters, and also support multiline cells form.

License

Notifications You must be signed in to change notification settings

Mr-sB/TinyCSV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinyCSV

Version 1.3.2

Tiny CSV toolkit for .NET. Easy to read and write CSV table.

Feature

  • 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.

Usage

More examples can be found in the TinyCSV.Example.

Reading a CSV file

var csv = File.ReadAllText("sample.csv");
//Create csv reader form csv content, custom cell separator.
CSVTableReader csvTableReader = new CSVTableReader(csv, 2, ',');

Writing a CSV file

//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);

Requirements

TinyCSV currently targets and supports

  • .NET Framework 4.0 and above.

About

Tiny CSV toolkit for .NET. Easy to read and write CSV table. Support cells contain comma and double quote characters, and also support multiline cells form.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages