0

I am using CsvHelper library to read through a list of records in a csv file, and would like to know how I can read loop through the list from a specific value or row.

My CSV file data:

123456
546879
258963
147852
654789
321654

Currently my code is as follows:

Currently my code:
int controlid = 0; //This value is read from a file 

using (CsvReader csvread = new CsvReader(inputFilePath))
IEnumerable<dynamic> records = csvread.GetRecords<dynamic>();

for (int i = controlid; i < records.Count(); i++)
{
    // I get "Argument out of bounds" error here
    customerID = records.ElementAt(i);

    console.writeLine(customerID);
    controlID++;
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
edcoder
  • 503
  • 1
  • 5
  • 19

1 Answers1

0
using (CsvReader csvread = new CsvReader(inputFilePath))
IEnumerable<dynamic> records = csvread.GetRecords<dynamic>();
records.SkipWhile(e => e != controlid).ToList().ForEach(e =>
{
       console.writeLine(e);
}

I hope this will help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kostarsus
  • 37
  • 5