Skip to content

ssharunas/LibCSV4Net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibCSV

Library for reading and writing tabular (CSV) files.

Cahnges

0.5

  • Improved CSVAdapter
  • Transformer supports transforming result for writing

0.4

  • Added CSVWriter

0.3

  • Changed IResultTransformer interface
  • IList TransformList(IList result) -> IEnumerable TransformResult(IEnumerable result);

0.2

  • 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

Example

  • 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();
	}
}

License

This is free software, and you are welcome to redistribute it under certain conditions; see LICENSE.txt for details.

Author contact

Darius Kucinskas d.kucinskas@gmail.com, http://blog-of-darius.blogspot.com/

About

Library for reading and writing tabular (CSV) files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%