Link to home
Start Free TrialLog in
Avatar of cookiejar
cookiejarFlag for United States of America

asked on

Loading .csv data into anarray

I am a beginner and would like to know how to load .csv data into an array.

Data:
"Leader",0,"Safety","00.00",03/14/2003,"4 of 5"
"Leader",0,"Plotter","00.01",03/21/2003","-2"
"Super",1,"Printer","00.02",04/21/2012",""

Loaded in rows and would like each comma delimited be a column
Avatar of Valeri
Valeri
Flag of Bulgaria image

ASKER CERTIFIED SOLUTION
Avatar of Valeri
Valeri
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also have a look at this google project.
Definitely for that kind of csv, use a dedicated parser as Valeri mentioned at the start. Personally i found opencsv to be slightly buggy (iirc) and have often used the Ostermiller csv class.

I don't know whether it's a copy-paste error, but your csv looks ill-formed:
"Leader",0,"Plotter","00.01",03/21/2003","-2"

Open in new window

has an odd number of quotes
Avatar of cookiejar

ASKER

Instead of reading from a .csv file, the data is stored in a static array.
"Leader",0,"Safety","00.00",20130314,"4 of 5"
"Leader",0,"Plotter","00.01",20130321,"-2"
"Super",1,"Printer","00.02",201204231,""

How would I loop through the array to access for example:
frst row  column 1 which is Leader,  column 2 which is 0,  column 3 which is Safety
second   row column 1 which is Leader, column 2 which is 0, column 3 which is Plotter
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial