From: Phrogz Date: 2007-02-07T01:55:12+09:00 Subject: Re: Parse csv similar file On Feb 6, 8:36 am, Drew Olson wrote: > I think he wants to append this array with information each time he sees > the same key, so modify your code like so: > > lines = DATA.readlines.map{ |line| > line.chomp.split( ';' )} > > lookup = {} > lines.each{ |data| > key = data.find{ |value| /^E/ =~ value } > lookup[ key ] ||= [] > lookup[ key ] << data > > } Curses, I didn't read carefully enough. Right you are. (And, though it's not clear from his example, he might not even need to split the original line into arrays of pieces, but just keep the lines.)