From: Qubert Date: 2003-04-24T14:26:08+09:00 Subject: parsing large file into matrix I work on a lot of flat files containing data with many columns and thousands of rows. I have recently started using ruby, in hopes to forgo the overworking of sed and awk or tedious coding of C. So far I like it. Question: It would be ideal if I could open a file, read in the data and then start working on the resulting array by a [m,n] indexing. Thus far using Ruby I can do this fairly quickly: x = File.open("file.txt").readlines j = 0 ffsize = Array.new name = Array.new while j < x.length y = x[j].split('\t') ffsize[j] = y.shift.to_f/1024.0 name[j] = y.shift j += 1 end Currently I am just using a small dummy file as a test, but this will become huge once I start using files with many columns of data and I will likely join these field arrays together again. Is there a Ruby-way of creating an m by n array from the beginning? I know the following doesn't work but something like it code would be nice: x = File.open("file.txt").readlines.split('\t') Then x would be an m by n array of m different data types. Thanks, Qubert