- Put the CSV file in your site's root directory (or other convenient place).
Put the CSV file on your CiviCRM server, outside the webroot somewhere. (Do not place this file within the website root, or you risk exposing your contacts' data to the internet.)
- In the command prompt (shell), type
php path/to/import.php -e Contact --file path/to/file.csv
(check this forum post for some more detail). Provide an absolute path to the CSV file.In the command prompt (shell), type
php path/to/import.php -e Contact --file path/to/file.csv
(check this forum post for some more detail). Provide an absolute path to the CSV file. - At this point, depending on the contents of your CSV file, you will likely get an error such as
ERROR line 2: Mandatory key(s) missing from params array: contact_type
. It expects you to pass a contact_type parameter inside the CSV file. If you don't have one in your exported CSV file, you can very easily add a contact_type column in it using a Notepad++ macro (note: turn off autocompletion for words and quotes in Notepadd++ as it may screw up the macro). Just add the new column at the end. Here is an example of a CSV file:At this point, depending on the contents of your CSV file, you will likely get an error such as
ERROR line 2: Mandatory key(s) missing from params array: contact_type
. It expects you to pass a contact_type parameter inside the CSV file. If you don't have one in your exported CSV file, you can very easily add a contact_type column in it using a Notepad++ macro (note: turn off autocompletion for words and quotes in Notepadd++ as it may screw up the macro). Just add the new column at the end. Here is an example of a CSV file:"email","contact_type"
"[email protected]","Individual"
"[email protected]","Individual" Now run the command again and you should see a success message for each imported contact. The message looks like this:
line 2: created Contact id: 114
"email","contact_type"
"[email protected]","Individual"
"[email protected]","Individual"
- Now run the command again and you should see a success message for each imported contact. The message looks like this:
line 2: created Contact id: 114