From: 7stud -- Date: 2007-10-08T23:11:05+09:00 Subject: Re: MATRIX PROBLEMS (AGAIN!) 7stud -- wrote: > > results = [] > > File.open("data.txt") do |file| > file.each_line() do |record| > fields = record.split(",") > fields.each do |field| > results << field.to_i > end > end > end > > p results You can also use the Standard Library module CSV(or get the gem FasterCSV) to easily read comma separated data: require 'csv' matrix = [] CSV.open('data.txt', 'r') do |row| row.each do |column| matrix << column.to_i end end p matrix -->[10, 20, 30, 40, 50, 60] -- Posted via http://www.ruby-forum.com/.