reading CSV record in an array

G

Guest

I read a CSV file using a stream reader.
I read a complete line using readline. I need to get hold of each column.
I can't use split function with a comma cos the contents in the columns
might have comma too.

How best to handle this?

I have to use a reader only in this case.

Thanks
PK
 
G

Guest

It seems to me that you should not be using comma-delimited files to exchange
data whose field values can contain commas. Consider advising the clients to
produce other formats (e.g. fixed-length) or to use a different delimiter for
exchanging data with your application.

A delimiter is "a character or sequence of characters marking the beginning
or end of a unit of data."
 
O

Otis Mukinfus

I read a CSV file using a stream reader.
I read a complete line using readline. I need to get hold of each column.
I can't use split function with a comma cos the contents in the columns
might have comma too.

How best to handle this?

I have to use a reader only in this case.

Thanks
PK
PK,
You will have to ask your client to delimit the fields with tabs. It is rare
for data meant for parsing to have tabs in the rows.

Another thought; Are the areas that have commas in the data surrounded by double
quotes? I've seen this before. If so you might try to determine a way to not
split on commas that are between quotes.

You have a nice puzzle to solve, my friend.

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

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

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top