# Newbie with a project.(Parse tabed file and gen statistics?)

**URL:** <https://www.ruby-forum.com/t/newbie-with-a-project-parse-tabed-file-and-gen-statistics/79043>\
**Category:** Ruby\
**Created:** [December 11, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/newbie-with-a-project-parse-tabed-file-and-gen-statistics/79043 "2006-12-11T19:59:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aceofaces](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@aceofaces](https://www.ruby-forum.com/u/aceofaces)\
**Post date:** [December 11, 2006, 7:59pm UTC](https://www.ruby-forum.com/t/newbie-with-a-project-parse-tabed-file-and-gen-statistics/79043/1 "2006-12-11T19:59:27Z")

</div>

I have tab delimited files that I want to parse and generate statistics  
with. I can parse the file into an array using IO.readlines but don’t  
know what good that does for sorting, and the other path I was following  
was this.

class MyNewClass  
File.open("/home/user/testdata") do |openfile|  
openfile.each do |iterationshere|  
status, keyword, location, state, zip, date, resultcount,  
searchcount = iterationshere.chomp.split(/\t+/)  
puts “keyword: #{keyword} status: #{status}, location: #{location},  
state: #{state}, zip: #{zip}, date: #{date}, resultcount:  
#{resultcount}, searchcount :#{searchcount}”  
end  
end  
end

This obviously gos through the file line by line and splits on the tab  
character and assigns the the variables status keyword etc then prints  
that line.  
But how do I put those into a hash and sort on the fields. Eventually I  
will need this to go into a database, but I want to take this one step  
at a time.  
Thanks for helping this newbie. I have been using Perl for a while  
(still consider myself newbie with it), but have decided to get more  
into web development using the Rails framework and noticed Ruby had  
regexp support built in. WOOT.
