Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Java - Parse CSV to JTable

  • 15-10-2012 04:39PM
    #1
    Registered Users, Registered Users 2 Posts: 8,324 ✭✭✭


    Note: I have to use the standard Java libraries so can't import CSVWrite library from opensource!!

    I'm just wondering what would be the best way to do the following (side note: I can do it with a standard terminal interface, but my project requires a GUI interface also)

    I have a CSV file that contains 6 columns per row. The first column is user name, and I'm using that as the identifier. I pass the user name to my CSVreadwrite class and call my readGUI method. For the console interface, I was passing the whole row into a String array (one dimensional) and cutting it at every iteration of ','. This worked grand.

    With the GUI, I was going to parse into a two dimensional array (I've seen a few things about Lists, which are in Weds lecture so that may void this whole thing!!) but I'm not 100% how it works.

    If I have tempVar[ x ][ y ], I know that x specifies the row, and y the column. I have my own userLine[] single dim array which is, say, { "username", "propertyname", "value", "taxPaid"}

    Can I specify that all that info from userLine[] goes into tempVar[0][y] at the y location, and then increment 0 to 1 for the next row. The CSV does organise on a date format, so it goes by when the item was added, rather than by alphabetical, so there is code to skip the line of userName does not match userLine[0]

    Hope that makes sense!


Advertisement