Skip a set amount of rows #2120
-
Hi I would like to import a CSV but skip the first 12 rows (as these are incompatible with my classmap). Right now I have this:
But this tries to convert the lines to a Transaction and then tries to skip the first 12 rows, but I get errors in the converting so I want to skip before the conversion. Hopefully this is possible. Kind regards |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
For the You can skip like this though. for (var i = 0; i < 12; i++)
{
csv.Read();
} If you have a header and it doesn't start on line 13, you'll need to read that separately. This also reads CSV rows, so if there are double quotes and other things in there you would want to skip file rows. for (var i = 0; i < 12; i++)
{
reader.ReadLine();
} |
Beta Was this translation helpful? Give feedback.
For the
Skip
call to work, the entire data set is read into memory first. There is no LINQ provider.You can skip like this though.
If you have a header and it doesn't start on line 13, you'll need to read that separately.
This also reads CSV rows, so if there are double quotes and other things in there you would want to skip file rows.