On Apr 17, 2007, at 1:40 AM, Stephen Smith wrote:

> So here's the problem: I have a CSV file that I need to munge into  
> a batch
> file for a mainframe to process. This file has many (say, 30 or  
> more) fixed
> width fields per record with distinct rules attached to each field  
> (e.g.,
> field1 is an eight-position date following the pattern YYYYMMDD,  
> field2 is a
> five-position enumerated customer type, field3 may contain either a  
> 70 or a
> 71 depending on the customer type, etc).

I'm a little confused by your description of the file.  You call it a  
CSV file and say it has fixed-width fields, but those are two  
different things.

Either way though, Ruby has the tools you need.

For CSV data, see the standard "csv" library.  For splitting up fixed  
width fields, a call to String#unpack will do.

Hope that helps.

James Edward Gray II