Library for reading and writing tabular (CSV) files.
- Improved CSVAdapter
- Transformer supports transforming result for writing
- Added CSVWriter
- Changed IResultTransformer interface
- IList TransformList(IList result) -> IEnumerable TransformResult(IEnumerable result);
- Redesigne of CsvReader interface
- Dialect must be set in constructor (removed property)
- Added header support to Dialect
- Added GetCurrentRecord
- Recorrd is returned as string array
- Added IResultTransformer
- Added Adapter class
- Define your Dialect
public class MyDialect : Dialect
{
public MyDialect()
{
DoubleQuote = true;
Delimiter = ';';
Quote = '"';
Escape = '\0';
SkipInitialSpace = false;
LineTerminator = "\r\n";
Quoting = QuoteStyle.QUOTE_NONNUMERIC;
Strict = false;
if (CheckQuoting() == false)
throw new Exception("bad \"quoting\" value");
}
}
- Now you can use it like this
using (CSVReader csvReader = new CSVReader(new MyDialect(), @"C:\CSV\MY_TEST.CSV", "windows-1257"))
{
while (csvReader.NextRecord())
{
string[] record = csvReader.GetCurrentRecord();
foreach(string item in record)
{
Console.Write(" " + item);
}
Console.WriteLine();
}
}
This is free software, and you are welcome to redistribute it under certain conditions; see LICENSE.txt for details.
Darius Kucinskas [email protected], http://blog-of-darius.blogspot.com/