我正在使用csvHelper库来读取csv文件中的记录列表,并且想知道如何读取特定值或行中的列表。
My CSV file data:
123456
546879
258963
147852
654789
321654
当前我的代码如下:
Currently my code:
int controlid = 0; //This value is read from a file
using (CsvReader csvread = new
CsvReader(inputFilePath))
IEnumberable<dynamic> records = csvread.GetRecords<dynamic>();
for (int i = controlid; i < records.Count(); i++)
{
customerID = records.ElementAt(i); // I get Arugument out of bounds error here
console.writeLine(customerID);
controlID++;
}
答案 0 :(得分:0)
using (CsvReader csvread = new
CsvReader(inputFilePath))
IEnumberable<dynamic> records = csvread.GetRecords<dynamic>();
records.SkipWhile(e => e != controlid).ToList().ForEach(e =>
{
console.writeLine(e);
}
我希望这会有所帮助。