From: Harry Date: 2007-03-30T14:25:13+09:00 Subject: Re: text processing On 3/30/07, Stephen Smith <4fires@gmail.com> wrote: > >The fields are fixed widths, each record is separated by a new line. > I need to get this data into csv format so I can import it into a mysql > database for analysis. > > I figure a script is the best way, but I'm stumped since the fields aren't > delimited. > > Any tips, suggestions, pointers or a script that does something similar > would be GREATLY appreciated. > This is sloppy but you get the idea. Try something like this. You can improve it. arr = ["abcdefgh","12345678","867-5309"] mydata = "" arr.each do |x| x =~ /(...)(.)(....)/ #grabs 3 characters, then 1, then 4 mydata << $1 + "," + $2 + "," + $3 + "\n" end puts mydata Harry -- http://www.kakueki.com/ruby/list.html Japanese Ruby List Subjects in English