I have a really big CSV file with about 1,000,000 rows and it takes about 500 MB of memory. I don't have to read all the file. I want read every one hundredth line from the file. I try to do it by ReadLines
, but it is really slow, faster is ReadAllLines
.
My code:
for (int i = 0; i < 10000; i++)
{
tableOfString[i]=File.ReadLines("TestCSV.csv").Skip(i*100).Take(1).First();
//or
tableOfString[i] = File.ReadLines("TestCSV.csv").ElementAtOrDefault(i*100);
}
I read about some readers:
Has anybody got a solution? I want to read only certain lines from the CSV, not the whole file.