Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java - Parse CSV to JTable

Options
  • 15-10-2012 4:39pm
    #1
    Registered Users 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