From: Nick da G Date: 2009-04-16T02:34:43+09:00 Subject: Re: Parsing Fixed Width File > It's pretty simple so I'm not sure that a library is needed > > fields = [5,12,5,2,20] #<- the size of each field > field_pattern = "A#{fields.join('A')}" > File.foreach(filename) do |line| > row = line.unpack(field_pattern) > ... #use row[0] etc for each field > end > > Andrew Timberlake > http://ramblingsonrails.com > http://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twain Yeah that's pretty much what I ended up doing. Created an object that defines each record (line) then pass it at a line from file, and get an object back that I can do what I want with - like outputing to csv . I was jsut wondering if there was a more simple and elegant solution. But I guess you can't go simpler than that. :-) Thanks for a response! -- Posted via http://www.ruby-forum.com/.