CSV contact import script

From Zarafa wiki

Jump to: navigation, search

The following script can import a csv file with contacts: Media:Csv2contacts.zip.
The script can be customized for different csv files.

The following lines should be changed to make a different mapping between the Zarafa contact fields and the fields in the csv file: The number correspond with the column in the csv file.

$csv_mapping = array(
                        "company"       =>      25,
                        "name"          =>      2,
                        "email"         =>      4,
                        "phoneoffice"   =>      6,
                        "faxoffice"     =>      8,
                        "phonemobile"   =>      10,
			"street"	=>	17,
			"street2" 	=>	18,
			"postalcode"    =>	21,
			"city"	        =>	19,
			"state"	        =>	20,
			"country"	=>	22,
);


You can run the script via the following command:

php csv2contacts.php username password name.csv

The csv should be stored in /tmp.