Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

strategy to read columns in File IO

 
Nitesh Nirala
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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.

 
Tony Docherty
Bartender
Posts: 2989
59
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you very much Tony.
 
Tony Docherty
Bartender
Posts: 2989
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My pleasure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic