From: Ryan Leavengood Date: 2005-08-03T02:41:30+09:00 Subject: Re: csv to hash ou_ryperd said: > Hi > I have a csv file with two fields per line. What would the most > effective way be to read it into a hash variable ? e.g.: > 10000,A > 10001,B > 10002,C > > I have searched ruby-talk and comp.lang.ruby and did not find a > suitable example. > thanks in advance Ruby comes with a CSV library: require 'csv' hash = {} CSV.foreach('test.csv') do |row| hash[row[0]] = row[1] end p hash Ryan