From: Matthew Margolis Date: 2004-09-26T03:22:52+09:00 Subject: Re: Formatting addresses question Daniel Kelley wrote: >Matthew Margolis writes: > > > >>I currently have a large text file based address book(for myself, not >>spamming) that I am working on making suitable for import into a >>database. To do this I need comma separated values. How would I go >>about adding a comma after the state in the person's mailing address? >> >>An example record: >> >>Name: Bob Fakeyhead >>Title: Old Boss >>Phone: 555-555-5555 >>Mailing: 23456 Something Street >>OldPlace, WA 55555 >> >> >> > > >If you are using Ruby 1.8, you can use the CSV module. > >http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/ > > > >:::::::::::::: >z.rb >:::::::::::::: ># ># z.rb ># ># Copyright (c) 2004 by Daniel Kelley ># ># > >require 'csv' > >writer = CSV.generate('csvfile.csv') >writer << ['Name', 'Title', 'Phone', 'Mailing'] >writer << ['Bob Fakeyhead', 'Old Boss', '555-555-5555', '23456 Something Street >OldPlace, WA 55555'] >writer.close > >:::::::::::::: >csvfile.csv >:::::::::::::: >Name,Title,Phone,Mailing >Bob Fakeyhead,Old Boss,555-555-5555,"23456 Something Street OldPlace, WA 55555" > > > Thanks for the reply but I already have decided on what database I will be using so I don't need CSV, I just need to find a way to insert a comma after the state in the person's address. -Matthew Margolis