Gmail contacts to AdaFruit SIM loader format

Talk about the videos and projects (SIM reader, payphones...)

Moderators: adafruit_support_bill, adafruit

Gmail contacts to AdaFruit SIM loader format

Postby rabbitnyc » Mon Sep 13, 2010 9:08 pm

Hope someone else will find this useful. Make sure to get and download the "Text::CSV_PP" CPAN libraries. To get your Google contacts log into your gmail account select contacts; More actions; export; google CSV format.

Gustav




Code: Select all
#!/opt/local/bin/perl

#Copyright 2010 by Gustav von Roth, Gmail2AdaSIM[at]vonroth.com
#
#This software is free software; you can redistribute it and/or modify
#it under the same terms as Perl itself.


use strict;
use warnings;

use lib '.';
use Text::CSV_PP;

if(($#ARGV+1) != 2)  {
   print "Gmail2AdaSIM.pl <infile.csv> <outfile.txt>\n\n";
   print
   "\n".
   "example usage:"."\n".
   "perl Gmail2AdaSIM.pl google.csv gmail2AdaSim.csv"."\n"
   ;
   exit;
}

my $inFile  = $ARGV[0];
my $outFile = $ARGV[1];

               
    #open input file            
    open my $gmail_csv_fh, "<:encoding(UTF-16)", $inFile or die "$inFile: $!";
    my $gmail_csv = Text::CSV_PP->new({ binary => 1});
    my $status = $gmail_csv->getline ($gmail_csv_fh);
    my @headerNames = $gmail_csv->fields();

    $gmail_csv->column_names (@headerNames);

    open my $AdaSim_csv_fh, ">", $outFile or die "$outFile: $!";
   
    #print header
   print $AdaSim_csv_fh "# Gmail2AdaSIM\n";
   print $AdaSim_csv_fh "# \"Name\", Number\n";
   
    my $memNumber=1;
   
   while (my $hr = $gmail_csv->getline_hr ($gmail_csv_fh))
   { 
      my $mobileNum;          
             
             for(my $i=1;$i< @headerNames;$i++)
             {
                #print $allKeys[$i] . "\n";
                if($hr->{$headerNames[$i]} eq "Mobile")
                  {
                     
                    $hr->{$headerNames[$i+1]} =~ s/[\(|\)|-]//g ;
                $hr->{$headerNames[$i+1]} =~ s/-/ /g ;

               
                     my($mobileNum ) = $hr->{$headerNames[$i+1]} =~ m/^([\+|\d|\s]*)/ ;
                     print $hr->{$headerNames[0]} .":". $mobileNum . "\n";
                     print $AdaSim_csv_fh "\"" . substr($hr->{$headerNames[0]},0,17) ."\"," . substr($mobileNum,0,19) . "\n";
                     $i = @headerNames + 1;
                  }
             } 
       $memNumber++;
    }  #while
    $memNumber--;
    print "Conversion complete!.\n  Converted $memNumber line(s);\n  Output in file: $outFile\n";

rabbitnyc
 
Posts: 1
Joined: Mon Sep 13, 2010 8:56 pm

Gmail contacts to AdaFruit SIM loader format

Postby earlagd » Sun Sep 30, 2012 2:46 am

I just installed Outlook 2010 on my computer. I cannot import my Gmail contacts. I export them onto my desktop but get an error message when I attempt to import. I have had the same problem when I have attempted to import contacts from Windows Live Mail. Any suggestions? Thanks
User avatar
earlagd
 
Posts: 1
Joined: Tue Sep 18, 2012 11:30 am
Location: United States


Return to Citizen Engineer (retired forum)

Who is online

Users browsing this forum: No registered users and 3 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [105]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]