StreamReader problem URGENT!

C

Christian Pické

Hi,

I have a problem with a CSV-file I have to read (actually I have to convert
it to a XML).

In some 'fields' of the CSV-file are some line-feed characters included (\r
??? don't know because I cannot capture them) (I suppose it are not carriage
returns). The problem is now that the StreamReader.ReadLine is considering
them too as an end-of-line, and not only the real carriage return.

As a result I am getting records that are incomplete and that is storing the
wrong data in the wrong fields on the next line when splitting the line on
the separator.

When I import the data in Access, I have the same problem, except when I set
the Text Qualifier to " (double quotes). Is there a similar thing I can do
with the StreamReader???

Any help will be appreciated very much.

Kind regards,

Christian
 
J

Jeff Callahan

christian,

according to the msdn page about StreamReader.ReadLine()
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html
/frlrfsystemiostreamreaderclassreadlinetopic.asp), the only end of line
sequences ReadLine uses are "\n" and "\r\n". the only way you'll be able
to use the ReadLine() method to get your logical lines is by ensuring that
none of your values include either of these characters. you could of
course sweep through the file and try to replace any occurrence of these
characters in your values, or you could always use one of StreamReader's
Read methods instead.

let me know if i can offer any other help.

jeff.

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
 
C

Christian Pické

I should have been thinking of that myself; reading one char at a time and
building the line only breaking on \n\r and not on \n only. I guess I must
have been very tired yesterday evening!

Thanks!!!
Christian
 

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