The Feeds module may be used to import Address Field data into entities containing address fields. Address Field stores the individual elements of an address separately (e.g. city, state, postal code), so your data source must differentiate these parts of the address using separate columns or elements.

When configuring your mapper, Feeds lets you select which part of the address field the data source maps to:

There are four important things to keep in mind with respect to address field data:

  1. When importing address data, you should always supply a country value. If your data source does not include a country (whether it's because all addresses come from the same country or some items in the data source have a country while others do not), you should use a module like Feeds Tamper to supply a default value. Address Field currently depends on the country to know if a field value is empty and to know how to build the address field widget form.
  2. Address Field identifies countries using their two character ISO 3166-1 country codes. If your source data uses the full name, you will need to change the way you create your source data or use custom code (perhaps working through Feeds Tamper) to convert the full country name into the corresponding country code.
  3. Address Field identifies administrative areas (i.e. State / Province) using their alphanumeric ISO 3166-2 codes for any country whose address field widget form uses a select list instead of a textfield to specify the administrative area. As above, if your source data uses the full name, you will need to convert the data for import. Address Field does not yet have a solid API for converting one to another, but interested developers can follow this related issue to be updated when it adds one.
  4. To import a separate house number (e.g. for postal code validation or lookup): map the number to the Address Data field; use Tamper to rewrite the value with a:2:{s:10:"huisnummer";i:[imported_number]";s:11:"houseNumber";i:[imported_number];}

For more information on configuring a Feeds importer, refer to the Feeds site builder documentation.

Resources

Comments

Stomper’s picture

I have a location taxonomy where each term uses the Address Field.

I'm trying to import via Feeds from a CSV into the Address Field of the taxonomy. For some reason, in the Select Target dropdown, I do not see any Address Field subfields.

Am I doing something wrong?

Also how would one use Feeds Temper, explode or implode, to import from a CSV to Address Fields?

hooface’s picture

subscribe

millionleaves’s picture

I hit an issue where my feed source was supplying the 3 character ISO country code, which broke the import. When I excluded the country field and ran the import again, the rest of the address data was ignored.

My source data was Ubercart for D6, and I was able to use the Feeds SQL module to write a raw query on the UC database that added the 2 character ISO country code instead. This was possible because the uc_countries table in Ubercart stores the country codes in several different formats.

I provide Drupal, Drupal Commerce and CiviCRM development services for customers in New Zealand and beyond

zlinedavid89’s picture

One note to add regarding the importing of US/Canada state/province data. The ISO3166-2 codes are used without the ISO3166-1 country code prefix. Example: The actual ISO3166-2 code for Ontario is "CA-ON". The import does not use the "CA-" prefix, just the "ON". Same issue for US states.

I'm not sure if this applies to other countries or not.

edvanleeuwen’s picture

I cannot choose the individual elements of the address when this field is attached to a Profile2 profile type. Only the parent field is listed. Does anyone know whether this is possible or not?
EDIT: See https://www.drupal.org/node/2423193 for a solution.

Best regards,

Ed

jukka792’s picture

Hi,
I can see, Country, and other fields like "premise" and postalcode but which one is the city?

mieg’s picture

It's called 'locality'.

Anybody’s picture

There is no solution for the core address field in Drupal 8 yet, isn't it?
I created an issue for that: #2962672: Add Feeds target for Address.

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes