CsvReader
. It is used internally for Row sorting. The following
example shows how to use for general purpose CSV parsing.
using (FileStream stream = new FileStream("my.csv", FileMode.Open, FileAccess.Read)) { using (CsvReader reader = new CsvReader(stream, Encoding.UTF8)) { reader.setStrict(true); // throw errors for bad formatting List<String> row; while ((row = reader.readRow()) != null) { // Process data Console.WriteLine("Row has {0} column(s)", row.Count); } } }
CsvWriter
. It is used internally for Row sorting. The following
example shows how to use for general purpose CSV writing.
using (var stream = new FileStream("o.csv", FileMode.Create, FileAccess.Write)) { using (CsvWriter writer = new CsvWriter(stream, Encoding.UTF8)) { int counter = 0; List<String> row = new List<String>(); for (int i = 0; i < 200; i++) { row.Clear(); for (int j = 0; j < 5; j++) row.Add(counter++.ToString()); writer.writeRow(row); } } }