Processing CSV Files...

I

Ian Craig Armitage

Hi,

As strange as it sounds, i need to convert a csv file from one csv layout to
another!...

Basically both have fields as the first line (terminated with a lfcr) but
after that the source file is pretty much continuous with a few lfcr's
through the file..

The output csv i require needs to have a "EOLEOL" at the end of each line
entry...

can anyone help me with the source code for this.. im using the free vb
express 2005.

Thanks
 
G

Guest

Hi,

As strange as it sounds, i need to convert a csv file from one csv
layout to another!...

Basically both have fields as the first line (terminated with a lfcr)
but after that the source file is pretty much continuous with a few
lfcr's through the file..

The output csv i require needs to have a "EOLEOL" at the end of each
line entry...


There is a project called "FileHelpers" on SourceForge which handles CSV
files. The project was a little buggy, but it has some nice helper
functions for CSV.
 
M

Michael D. Ober

If the only thing changing is the end of line marker, do the following:

dim fIn as new IO.StreamReader("source.csv")
dim fOut as new IO.StreamWriter("target.csv", False,
System.Text.Encoding.ASCII)

do while not fIn.EndOfStream()
fOut.Write(fIn.ReadLine() & "EOLEOL") ' Note that the write is not a
writeline - you are specifying the end of line marker.
loop
fIn.Close()
fOut.Close()

Mike.
 

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

Top