Processing CSV Files...

  • Thread starter Thread starter Ian Craig Armitage
  • Start date Start date
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
 
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.
 
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.
 
Back
Top