473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

reading CSV record in an array

P K
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

Feb 20 '06 #1
3 1281
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."
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"P K" wrote:
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

Feb 21 '06 #2
On Mon, 20 Feb 2006 15:22:27 -0800, P K <PK@discussions.microsoft.com> wrote:
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
Feb 21 '06 #3
I sell a parser for .net that handles all of these problems,
http://www.csvreader.com .

Bruce Dunwiddie

Feb 21 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: AMT2K5 | last post by:
Hello. I have a file (for a school assignment) with the following format and delimiter format. Each record in the file has the following format: 123423454567987,29873,James,Ha­rry,St....
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
3
by: Matt Laver | last post by:
Hi, I have a binary file that I'm currently reading byte by byte using code similiar to: string FileName = @"c:\myFile.dat"; FileStream fs = new FileStream(FileName, FileMode.Open,...
6
by: Neil Patel | last post by:
I have a log file that puts the most recent record at the bottom of the file. Each line is delimited by a \r\n Does anyone know how to seek to the end of the file and start reading backwards?
23
by: shank | last post by:
I have the below code found on an ASP site. <% arrName = Split(Request("TextArea"),",") %> <% For i = LBound(arrName) To UBound(arrName) Response.Write "ID: " & arrName(i) & "<br>" Next %>
1
by: bbepristis | last post by:
Hey all I have a wired issue I have a csv file with , seperated values I have some code to read the file and put the record into an array then into textboxes. the problem is it seems to read...
6
by: arne.muller | last post by:
Hello, I've come across some problems reading strucutres from binary files. Basically I've some strutures typedef struct { int i; double x; int n; double *mz;
9
by: peter.bremer | last post by:
Hi all, I've got a SQL Server database that contains zipped information stored in (binary) image fields. To complicate things, this zipped data is combined with plain-text data. I've verified...
2
by: GeoUK | last post by:
Hi All, New member here with a bit of problem. I have read the FAQ's and searched text books but still cannot solve the problem that I have. As part of a course I am doing at University I had...
1
by: jtnpham | last post by:
Is there any possible way to first pull informatio from a table, and then "read" all fields into an array? For example: My table has fields Center, Name, Capacity. After displaying the table in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.