Thanks for the code example! I'll play around with it and reply with my mishaps..er results. The multiple assignment aspect of it may be the key that I need.
Regarding your question about the line:
- ruby Code
values[ header[index] ] = data[index]
It had come about from playing around in irb where I had made the hash I wanted, but where I forgot how I did it. Grrrr
I have three rows in the csv indexed by 0,1,2. For each iteration of reading the row,
header now becomes 'email',
header becomes 'name'
header becomes 'id'
data is the first element of the data array giving me the actual email address.
making values a hash of "email' => "email@example.com" and so on, for each row.
This is possible because header.each_index loops through the index numbers 0 1 2 starting it off.
Again the answer is probably some simple multiple assignment, but I haven't the understanding yet.
For anyone's reference, I'm going through the Ruby template article by Herrington from freshmeat here: http://freshmeat.net/articles/view/447/
to make a mail merger script. Combined with win32ole module, it's possible to automate Outlook... or so I believe