• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

strategy to read columns in File IO

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have got a huge csv file. Some sample records are given below:

#station,t1,t2,t3,É,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Parliament,-,-,-,-,-,5:30,-,5:46,-,5:57,-,6:16,6:27
Melbourne Central,-,-,-,-,-,5:32,-,5:48,-,5:59,-,6:18
Flagstaff,-,-,-,-,-,5:33,-,5:49,-,6:00,-,6:19,6:30
Southern Cross,-,-,-,-,-,5:35,-,5:51,-,6:02,-,6:21,6:32

Detail records can be seen here webpage. (Each train schedule needs to be one object in this case)

I want to create each column as an object (not row) i.e t1,-,-,- (column 2) as one object and then t2,-,,(column 3) as another and so on.

What is the best way for accomplishing this? Will appreciate your response.

 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand why you want to store the information in columns when it's clearly related by row but the easiest way is to have an ArrayList object for each column and as you parse the file add each piece of data to the appropriate ArrayList. If you know the number of columns you could store the ArrayLists column objects in an array (otherwise you could store them in an ArrayList).
 
Nitesh Nirala
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Tony.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My pleasure.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic