The online Google Contacts page lets you export in CSV or vCard. CSV doesn't work with Nokia PC Suite (it might with some Excel magic), so I went with vCard. Problem is, PC Suite only imports 1 vCard/file, and Google exports all-in-one. After a quick unhappy Google, I came up with the following PHP commandline script to chop it up. It's ugly, but works... It takes the input from STDIN, and outputs to the folder specified in the code.
#!/usr/bin/php <?php $filenum=1; while ($SOR=fgets(STDIN)) { if (strstr($SOR,"BEGIN:VCARD")) { $filep=fopen("/home/tamas/temp/".$filenum.".vcf","w"); echo $filenum."\n"; } fwrite($filep,$SOR); if (strstr($SOR,"END:VCARD")) { fclose($filep); $filenum++; } } ?>Usage:
$ cat downloaded.csv | php vcardchop.php
No comments:
Post a Comment