Avatar of cookiejar
cookiejar
Flag 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
Java

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
Valeri

ASKER CERTIFIED SOLUTION
Valeri

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
girionis

You can also have a look at this google project.
CEHJ

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
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
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.