Skip to content

vcard format

Probably vcf stands for VCard Format. This is mostly about getting address information from an android phone to a usable address list.

getting via usb

Easiest way is to connect via usb and export the list :

On android go to :

  • Dialler
  • Contacts
  • Menu
  • Import/Export
  • Export to storage

It says where it will put the .vcf file. Remember it, in my case it was

changetitle
SDCard/00001.vcf 

Also, be sure to mark what you want to save. It looks like all are selected (V) but without selection no file is generated.

To get the file make your sdcard reachable :

  • Setting
  • Developer settings
  • Networking, Select usb configuration
  • Media transfer protocol

You can see the sdcard appearing when selecting. Now browse to sdcard and copy the file

vcf2csv

The format of the csv file is readable but not very practical :

changetitle
BEGIN:VCARD
VERSION:2.1
N:langeberg;edwin;;;
FN:edwin langeberg
END:VCARD
BEGIN:VCARD
VERSION:2.1
N:vd;&;;;
FN:& vd
EMAIL;PREF:almmeer@caiway.nl
NOTE;ENCODING=QUOTED-PRINTABLE:=4D=69=64=64=6C=65=20=4E=61=6D=65=20=3A=20=50=61=75=6C=0A=54=69=74=6C=
=65=20=3A=20=41=64=0A=43=61=6C=6C=69=6E=67=20=43=68=6E=20=3A=20=4D=65=
=65=72
END:VCARD

So you can use thus tool to at least make .csv from this link : _[https://sourceforge.net/project/platformdownload.php?group_id=223241]{.title-ref}

Unzip it, there is an executable inside.

changetitle
1
2
3
4
cd ~/Install 
tar -zxvf ~/Downloads/vcf2csv-0.6-201011061941-src-bin.tgz
cd vcf2csv-0.6-201011061941-src-bin/
./vcf2csv -i ~/Desktop/00001.vcf > contacts.csv

It won't handle these strings very well :

changetitle
NOTE;ENCODING=QUOTED-PRINTABLE:=4D=69=64=64=6C=65=20=4E=61=6D=65=20=3A=20=56=0A=4D=69=64=64=6C=65=20=
=4E=61=6D=65=20=3A=20=56

Ok .. this is enough to build my own parser, because this things sucks.

tools/vcfparser

A small practice prog to overcome problems with vcf2csv, it has been kept very simple, skipping all lines that are not in the colon (:) format.

  • When BEGIN is encountered a new Card is created
  • FN: is put into Card.name
  • TEL;CELL: is put into Card.number
  • EMAIL;PREF: is put into Card.email
  • When END is encountered the Cars is added to an ArrayList

So it parses email, but in the output i only print name,number but it is of course no rocket science to alter it to include email.

Call with :

changetitle
java -jar tools.jar 00001.vcf > contacts.csv