So I’ve been digging into Ruby for the past week, and I’ve come across
interesting problem that I want to solve with my new friend. Only I
want to reinvent the wheel.
So here’s the problem: I have a CSV file that I need to munge into a
file for a mainframe to process. This file has many (say, 30 or more)
width fields per record with distinct rules attached to each field
field1 is an eight-position date following the pattern YYYYMMDD, field2
five-position enumerated customer type, field3 may contain either a 70
71 depending on the customer type, etc). Say, ~10K records per batch
(plus header, subheaders, footers, and possibly addendums) and the batch
file has to get rebuilt nightly, plus a great big monthly summary file
composed of all the nightly files strung together. I want to go from csv
batch file automagically, and just writing a one-off for this one file
format seems like a total waste of time.
There are a bizillion of these formats out there, and I have to imagine
spooning csv files into yet another format is pretty common. I’m
if Ruby already has a batch file library, something like text-format.rb
If not then I’m going to write one… but right now I’m also likely to
something that looks way more like C than Ruby.
Any tips, pointers, hints, and otherwise code that might exemplify the
way to go about it would be much appreciated. Thanks in particular to
ruby local out there who might take a sec to point a tourist in the