OTRS: importing an Outlook contacts format CSV to the Address Book
Posted 06-26-2011 at 10:24 AM by catkin
Hello
Here's a script and associated SQL to import data from an Outlook contacts format CSV file into OTRS' Address Book.
They were developed and tested using:
A sample usage:
The attached file has had .txt added to its name to suit LQ's upload file name restrictions; it can sanely be removed after download. Alternatively, especially for those without an LQ registration, it can be downloaded from http://pastebin.com/1pK7i9Uj.
The script does all it practically can to sanitise the contacts data and where it fudges the data to meet OTRS "not null" database column requirements it annotates the value with a "fudged" comment to facilitate manual clean up in OTRS after loading. All the same it's probably worth running the script and checking the log to identify data issues and fixing them before running the script for the last time. If doing so, it's a lot easier to load the Outlook contacts format CSV file into a spreadsheet editor rather than use a text editor.
To load the output CSV into OTRS (only the '/tmp/contacts3.csv' should need changing):
In case of any feedback, problems etc. please comment in this blog entry.
Best
Charles
Here's a script and associated SQL to import data from an Outlook contacts format CSV file into OTRS' Address Book.
They were developed and tested using:
- An Outlook contacts format CSV file generated by export from Google Mail.
- gnu awk 3.1.8 on Slackware64 13.1.
- OTRS 3.0.8 running on Debian Squeeze 64 bit using mysqld and mysql 5.1.49.
A sample usage:
Code:
bin/Outlook_CSV_to_OTRS_CSV.awk -u1000 \ -i "Test inputs/contacts3.csv" \ -l /tmp/Outlook_CSV_to_OTRS_CSV.log \ -o /tmp/contacts3.csv
The script does all it practically can to sanitise the contacts data and where it fudges the data to meet OTRS "not null" database column requirements it annotates the value with a "fudged" comment to facilitate manual clean up in OTRS after loading. All the same it's probably worth running the script and checking the log to identify data issues and fixing them before running the script for the last time. If doing so, it's a lot easier to load the Outlook contacts format CSV file into a spreadsheet editor rather than use a text editor.
To load the output CSV into OTRS (only the '/tmp/contacts3.csv' should need changing):
Code:
load data infile '/tmp/contacts3.csv' into table customer_user fields terminated by ',' optionally enclosed by '"' escaped by "\\" lines terminated by '\n' ignore 1 lines ( change_by, @change_t, city, country, create_by, @create_t, customer_id, email, fax, first_name, last_name, login, phone, mobile, street, title, valid_id, zip ) set change_time = STR_TO_DATE(@change_t, '%Y-%m-%d %H:%i:%s'), create_time = STR_TO_DATE(@create_t, '%Y-%m-%d %H:%i:%s') ;
Best
Charles
Total Comments 0