I’ve decided on a small project to attempt to learn Ruby beyond just flipping
through the book. By the way, I can’t say enough good things about the pickaxe
book. I picked it up in spite having the electronic version.
I would like to read in a tab (or comma) delimited text file one line or one
item at a time. The input file might look like this:
col1,col2,col3
a,b,c
d,e,f
g,h
j
Note that there is not the same amount of data in each column. It could vary.
What is the best way to read this in from a file? When I’m done I would like to
have all the items in col1 in an array, all the items in col2 in an array, and
so on.
I’m sure this is a rudimentary task, but I would like to see the most elegant
ways in which Ruby permits something like this to be done.
Any other thoughts very much appreciated!
Thanks very much in advance!
Christopher
Christopher J. Meisenzahl CPS, CSTE
Senior Software Testing Consultant
Spherion
christopher.j.meisenzahl@citicorp.com