remove line from excel file

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.
 
N

nicknack

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.
 
N

nicknack

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top