• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to read data from a csv file and compare and display  RSS feed

 
Dan Foster
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 3 csv files as follows -
author file columns - emailID | firstname | lastname
books file columns - title | isbn | author_email | description
magazine file Columns - title | isbn | author_email | releasedate

I need to display -
1) Based on the ISBN display all books and magazines
2) All books and magazines by an author
3) All books and magazines by title

I am using Buffered reader as of now -



I am confused about how to proceed with multiple files. Here are the approaches that i have considered -

1) change string csv csvFileToRead to a string array - String[] csvFileToRead = {"data/autoren.csv", "data/buecher.csv", "data/zeitschriften.csv"};
Pass each index each time to a method returning all rows but getting stuck with DS to use. I think ArrayList wont suffice since i need separated data. Should i use a 2D array? Do i need to read and store data in a DS in order to achieve the goal?
2) Should i make 3 different classes with getters and setters for authors, book and magazine?

What is the ideal way to do this? Please suggest.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I'd use one of the many available CSV libraries: see "Excel" in http://www.coderanch.com/how-to/java/AccessingFileFormats for a list. Most of those provide an object model to work with.
 
Dan Foster
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I completed the code and have 3 methods for the data i needed to display. Since the return type of all these methods is void, can anyone tell me how to test these methods using JUnit? Moreover I have 3 more methods which extract and return data to the specific and the return type is List<authors>. How can i test these methods?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!