The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Reading CSV File

I have a CSV file with 16K entries of a data table.

Does Java work well with CSV file? Sorry I am a complete noob

--- Update ---

Okay, so I found this code. And it seems its quite easy to read in the data I need. Say for example if I wanted a loop to randomly pick the first field of a specific line in the CSV data table. How would i go about coding that??????

The CSV looks like the above. and I basically would like to read in the Hand to get it to show in a text box and then randomly have the program ask me to correctly identify the True/False return for one of the SB/BB/UG/MP/CO/BN columns. As you can prob tel i am not very good with Java... so i am stumbling my way through this. I know what I would like to do it, its just a case of how I get there!!!

Re: Reading CSV File

You use the word "randomly," but what you mean by it isn't clear.

What you describe (I think) could be done relatively simply by someone who has a good understanding of OOP with Java and is beginning to learn GUI programming using Swing. I don't know where you are on the knowledge and experience scale, but here are the Swing tutorials to get you started on the GUI using Swing part. Ignore the biased advice to use the Netbeans GUIBuilder and learn to code the GUI "by hand."

Re: Reading CSV File

Thanks for the reply. That link is useful and i will have to read it quite a few times. As I am a complete beginner with limited free time to read up on Java, but the time I do have spare I spend trying to learn as much as I can.

Sorry if I dont explain things well, English isn't my first language. I wish to have some kind of loop or iteration? that selects the "hand" as above, say for example [A9][A9] and displays this within a text box, then at the same time, another text box requres me to enter the correct T or F figure for any one of the T or F fields for that hand.

And then the loop to work through the list of rows. Above is a sample - there are actually 16432 rows in the .CSV that i am using.

Re: Reading CSV File

I recommend you create a Hand class that contains the attributes shown in each line. Read a line from the file, parse as needed, send the parsed data to the Hand constructor, and add the new Hand instance to a collection of some kind. Create methods in the Hand class as needed to provide the rest of the functionality you describe.

As for the GUI interface part, you'll have to add that as you learn how. If you're in a hurry to get your idea working, you might get the functionality working from the command line first and then add the GUI when you've learned how.