LINQ to CSV using DynamicObject(thinqlinq.com)
submitted by
KodefuGuru(2818) 2 years, 5 months ago
When we wrote LINQ in Action we included a sample of how to simply query against a CSV file using the following LINQ query:
1.From line In File.ReadAllLines(“books.csv”) 2.Where Not Line.StartsWith(“#”) 3.Let parts = line.Split(“,”c) 4.Select Isbn = parts(0), Title = parts(1), Publisher = parts(3)While this code does make dealing with CSV easier, it would be nicer if we could refer to our columns as if they were properties where the property name came from the header row in the CSV file, perhaps using syntax like the following:
|category: Linq
|Views: 40
tags:
LINQ another
Everyones tags:
Your Tags: