Created
December 26, 2008 00:57
-
-
Save moro/39985 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# vim:set fileencoding=utf-8 filetype=ruby | |
$KCODE = 'u' | |
require 'rubygems' | |
require 'csv' | |
require 'vpim/vcard' | |
data = Vpim::Vcard.decode(ARGF).map do |vcard| | |
next unless addr = vcard.address | |
full_addr = [addr.region, addr.locality, addr.street].map{|s| s.strip }.join(" ") | |
spouse = if line = vcard.lines("X-ABRELATEDNAMES").first | |
line.value | |
else | |
"" | |
end | |
[vcard.name.fullname, spouse, addr.postalcode, full_addr] | |
end.compact | |
CSV.generate("/tmp/address.csv"){|writer| data.each{|row| writer << row } } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment