This project is read-only.

Project Description
Linq2File is a helper for developer who need to parse files or streams in any format: csv file, flat file.
No worry about how to parse a file. Just a class decorated with the right attributes used by Linq2File to generate a strongly typed enumerator.

Project documentation and tutorials

Input file Examples


Code to parse a file

Simple query:

using (FileQuery<FlatTable> fileQuery = new FileQuery<FlatTable>(@"InputTestFiles\Book1.txt"))
fileQuery.Content.Where(i => i.Field2 != 12).ToList().ForEach(i => Console.WriteLine("{0} {1} {2}", i.DateField, i.Field1, i.Field2));

Advanced query:

using (FileQuery<Compte> fileQuery = new FileQuery<Compte>(@"InputTestFiles\Comptes.csv")) 
fileQuery.Content.GroupBy(i => i.Date.Year).Select(i => new { Year = i.Key, Total = i.Sum(g => g.Amount) }).ToList().ForEach(i => Console.WriteLine("Total for year {0}: {1}", i.Year, i.Total));

Last edited Aug 15, 2011 at 10:10 PM by paillave, version 7