how can I create a flat file in ruby?
Flat file is there each letter is placed at a specific column number in the file.
So for example if I am reading some values from the DB:
Name Class
-------------------
one A
two English
three Math
four Science
and I want to make a flat file out of it where names are to be between columns 1 to 10 and class is to be between columns 20 to 30. How can I make that file? I know how to write to a file but don't know how to write to a file...with specified columns...?
I tried sprintf from Mladen Jablanović answer
C:\>ruby parse.rb
2342342423
SOMETHING
2342
01/03/2010SDSDFS
234234
sprintf on array 2342342423SOMETHING 2342 01/03/2010SDSDFS234234