From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: Basic vcard-to-org-contacts converter Date: Tue, 25 Mar 2014 08:07:13 +0800 Message-ID: <87ior387ke.fsf@news.tumashu-localhost.org> References: <8761n39z76.fsf@posteo.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSF1h-0002xN-Fm for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 20:15:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSF1c-0005M9-RS for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 20:15:33 -0400 Received: from plane.gmane.org ([80.91.229.3]:40568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSF1c-0005M1-LU for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 20:15:28 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WSF1a-0003x0-I2 for emacs-orgmode@gnu.org; Tue, 25 Mar 2014 01:15:26 +0100 Received: from 120.4.245.127 ([120.4.245.127]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Mar 2014 01:15:26 +0100 Received: from tumashu by 120.4.245.127 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Mar 2014 01:15:26 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Titus von der Malsburg writes: > Hi list! > > I decided to give org-contacts a try. Since there doesn't seem to be a > facility for importing contacts in vcard format, I wrote a little Python > script for that. Perhaps someone on this list finds it useful. > > https://gist.github.com/tmalsburg/9747104 > > The script uses the Python package vobject for parsing vcard files. On > Debian-like systems this package is available as python-vobject. I > tested the script with contacts exported from Apple's iCloud service and > that worked well. However, the vcard format is somewhat messy and I > don't know what happens with vcard files generated in other contact > managers. Use at your own risk. Import from csv is a solution too, I use the below hack functions to import a csv file... #+begin_src (defun eh-org-contacts-parse-csv-line (line) "Build a org contact from a csv line" (let ((list (split-string line ","))) (concat "* " (nth 0 list) "\n" ":PROPERTIES:\n" ":PHONE: " (nth 1 list) "\n" ":EMAIL: " (let ((string (nth 2 list))) (if (string-match-p "@" string) string (if (> (length string) 0) (concat string "@qq.com")))) "\n" ":NOTE: " (mapconcat 'identity (nthcdr 3 list) "; ") "\n" ":END:\n"))) (defun eh-org-contacts-csv-import (&optional filename) "Convert a csv file to org contacts format and insert current point" (interactive) (let ((file (if filename filename (read-file-name "CSV file:"))) (buffer (current-buffer)) (point (point)) contacts-string) (with-temp-buffer (insert-file-contents file) (goto-char (point-min)) (while (< (point) (point-max)) (setq contacts-string (concat contacts-string (eh-org-contacts-parse-csv-line (buffer-substring (point) (progn (end-of-line) (point)))) "\n")) (forward-line 1) (beginning-of-line 1))) (switch-to-buffer buffer) (goto-char point) (insert contacts-string))) #+end_src > > If there's interest, I might migrate the script to a proper Github > repository and develop it further, i.e., merge your pull-requests ;-) > > Titus --