• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Data Type for a CSV File processing problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am breaking my head on this problem to find a suitable data type to use, but I am not able to settle with which one would be the most efficient and simple way to program this without using any third party libraries:

Problem:
Consider Share prices for a N number of companies given for each month since year 1990 in a CSV file. Format of the file is as below with first line as header.

Year,Month,Company A, Company B,Company C, .............Company N
1990, Jan, 10, 15, 20, , ..........,50
1990, Feb, 10, 15, 20, , ..........,50
.
.
.
.
2013, Sep, 50, 10, 15............500

Output:
List for each Company year and month in which the share price was highest.

I've considered using trees, Hashmap, Lists but I am unable to finalise THE ONE solution. I am a newbie to Java with a couple of weeks of Java coding experience so far. Any help in the form of pseudo code, program or what data type to use is appreciated.
 
Marshal
Posts: 77566
372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

We have an FAQ about different file types; that might help you. Try under “Excel”.
 
Campbell Ritchie
Marshal
Posts: 77566
372
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you need a Company class or a SharePriceHistory class.
 
James Joe
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Campbell Ritchie. But the constraint here is that the CSV parsing has to be done without using third party libraries.
I have the following so far, but I think I am not heading the right way. The csv parsing is turning out to be very messy and complicated:

Any suggestion with the CSV parsing to fit the solution? I have reached a dead end!

 
Rancher
Posts: 43077
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say partly that's a reflection that CSV is not quite as trivial as it first looks, and partly a reflection that the contents of the file you're dealing with have a structured format, i.e. not entirely trivial, either.

One thing I would do differently is using collections instead of arrays, so that I wouldn't have to worry about array sizes.

But the constraint here is that the CSV parsing has to be done without using third party libraries.


Why is that? The parser doesn't implement all CSV features yet, so it's going to get more complicated - something an open source 3rd party library can help avoid safely.
 
What are you doing? You are supposed to be reading this tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic