Created
November 22, 2009 13:46
-
-
Save ahx/240567 to your computer and use it in GitHub Desktop.
Einfache Umwandlung von aus Outlook exportiertem CSV (Win XP, Deutsch) in Apple Adressbook VCF
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 | |
| # encoding: UTF-8 | |
| # Umwandlung von Outlook exportiertes CSV (Win XP, Deutsch) in Apple Adressbook VCF | |
| # Usage: | |
| # csv2vcf adressen.csv > adressen.vcf | |
| # requires Ruby 1.9 | |
| require 'csv' | |
| table = CSV.parse(IO.read(ARGV[0]), headers: true) | |
| output = "" | |
| table.each do |r| | |
| vcard = <<-VCARDTEMPLATE | |
| BEGIN:VCARD | |
| VERSION:3.0 | |
| N:#{["Nachname","Vorname","Weitere Vornamen","Suffix"].map{|a| r[a]}.join(";")} | |
| ORG:#{%w(Firma Abteilung).map{|a| r[a]}.join(";")} | |
| TITLE:#{r["Position"]} | |
| EMAIL;type=INTERNET;type=HOME;type=pref:#{r["E-Mail-Adresse"]} | |
| EMAIL;type=INTERNET;type=HOME:#{r["E-Mail 2: Adresse"]} | |
| URL:#{r["Webseite"]} | |
| TEL;type=HOME:#{r["Telefon privat"]} | |
| TEL;type=HOME;type=FAX:#{r["Fax privat"]} | |
| TEL;type=HOME:#{r["Telefon privat 2"]} | |
| TEL;type=WORK;type=pref:#{r["Telefon geschäftlich"]} | |
| TEL;type=WORK:#{r["Telefon geschäftlich 2"]} | |
| TEL;type=WORK;type=FAX:#{r["Fax geschäftlich"]} | |
| TEL;type=CELL:#{r["Mobiltelefon"]} | |
| item1.ADR;type=WORK;type=pref:;;#{["Straße geschäftlich", "Ort geschäftlich", "Postleitzahl geschäftlich", "Land geschäftlich"].map{|a| r[a]}.join(";")} | |
| item1.X-ABADR:de | |
| item2.ADR;type=HOME:;;#{["Straße privat", "Ort privat", "Postleitzahl privat", "Land privat"].map{|a| r[a]}.join(";")} | |
| item2.X-ABADR:de | |
| BDAY;value=date:#{(bday = r["Geburtstag"]) == "0.0.00" ? nil : bday } | |
| NOTE:#{r["Notizen"]} | |
| END:VCARD | |
| VCARDTEMPLATE | |
| output << vcard | |
| end | |
| puts output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment