Avatar of 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.

"Leader",0,"Safety","00.00",03/14/2003,"4 of 5"

Loaded in rows and would like each comma delimited be a column

Avatar of undefined
Last Comment

8/22/2022 - Mon


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

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:

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

Instead of reading from a .csv file, the data is stored in a static array.
"Leader",0,"Safety","00.00",20130314,"4 of 5"

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
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.