Read a CSV file with Linq
April 27, 2012
Posted by on
I just wanted to post a small code snippet, for future reference, that reads a CSV file into List of string arrays.
rawFile = (from line in File.ReadAllLines(fileName).AsParallel()
File.ReadAllLines() reads all the lines from the csv into array of comma separated strings. Each line is split based on the comma into an array of strings. AsParallel() attempts to process the whole operation with multiple parallel threads.