remove line from excel file

  • Thread starter Thread starter nicknack
  • Start date Start date
N

nicknack

Hello.
I'm Reading data from an excel (CSV) file with header row and its
fine.
Now I have a file with one more line in the start (above the header)
and it giving me a lot of problems.

is there a way from C# to open the csv file and remove the first line?

If not as excel then maybe I'll just open it as a text file and remove
it (I know whats the string I want to remove).

Whats the fasted way to remove a string from the beggining of a txt
file?

Thanks.
 
What method are you using to read the CSV file?

Hi,
I'm connecting useing an oledb connection and filling a dataTable with
dataAdapter.

But the problem is that I need to remove the line before the reading
start since its a line with only one cell with a text.

I need to first remove the line, save the file and only then read it
with the oledb.

Thats what I think but I don't know how to remove it.

Thanks.
 
Hi Mark,

Thanks for the reply.

The "HDR" doesn't work as you said, for more then one row.

What I did at the end was to read the file (file.readAllLines) and
then create it again after discarding the first line.

Not very elegant but work :)

Thanks again!

roy.
 
Back
Top