Closed zandiarash closed 6 months ago
If you want to skip 7 lines, you could do it in the stream before CsvHelper gets involved.
Otherwise you can use the RawRow
to skip file lines. Row
is the logical CSV row since a CSV row could have line breaks in it.
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
ShouldSkipRecord = args => args.Row.Parser.RawRow < 8
};
and third line
I'm not sure what you mean by that.
Sorry, I've edited my question. @JoshClose
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
ShouldSkipRecord = args =>
{
var rawRow = args.Row.Parser.RawRow;
return rawRow < 8 || rawRow == 9 || rawRow == 10;
}
};
args
gives you the row to examine so you get get fields from it to test if you want to skip also.
Wow, That amazingly works, you are the best dear @JoshClose ❤️
I have a csv file like this
'some lines to skip : line 1 to 7'
Name,Family,Mobile
'line nine: should be skipped'
'line ten: should be skipped'
A,B,1
C,D,2
How Can I skip first seven lines, 9th and 10th line with ShouldSkipRecord by RowIndex?
I've searched a lote but I did not find any solutions
this is my codes