3

I have a local test environment on a mac where the site is installed.

I'm trying to do a CLI import via the mac terminal and unfortunately, address details are not being imported.

Command Used: php [absolute path]/sites/all/modules/civicrm/bin/csv/import.php -e Contact --file [absolute path]/csv/test.csv

Column headers: "contact_type","email","first_name","middle_name","last_name","street_address","city","state_province","country","gender","custom_1"

Sample CSV: "Individual","[email protected]","FirstName","MiddleName","LastName","Street Address Details","City Name","State Name","Country Name","Female","custom_1 value"

As you can see above, there's even a custom value and it get's imported, but address details are not.

Please help.

Mac: El cap, Drupal: 7, CiviCRM: 4.7

1 Answer 1

4

The CLI Contact import is meant to work on a per-entity basis, since it uses the API. So Contact is a separate entity from Address. The Contact entity API has a couple of hacks to accept certain parameters from other APIs - e.g. primary email address - but generally speaking, what you're doing is unsupported.

If you'd like to do what you're doing via command-line, you have a couple of options:

  • Pull the contact ID into your CSV, and do a second import using the Address entity.
  • Write a small PHP script that handles this using the API Chaining rules.
  • If you're super-ambitious, you could write support for API Chaining into the existing CLI import, or submit a paid issue queue item to the core team to do so.

If this is a one-time import and you're not a coder, the first choice is the easiest. Do your initial contact import first. I use a tool called Pentaho Kettle to automate the process of substituting contact IDs into my address etc. imports - but it's got a steep learning curve if this is a one-off job. Instead, export contact ID and external identifier from Civi, open it in a spreadsheet program, and use a VLOOKUP formula to generate your address import.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.