reading CSV record in an array

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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."
 
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

Similar Threads

CSV creation 3
.csv Commas ? 2
Read csv to 2D array 2
Reading large csv-file and removing duplicates 11
csv files 1
read csv 9
Read CSV into GridView 3
.csv Re-Format Question 1

Back
Top