CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • a way to fix incorrect country/state data
Pages: [1]

Author Topic: a way to fix incorrect country/state data  (Read 1115 times)

daveatkins

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
  • CiviCRM version: 4.1.6
  • CMS version: Drupal 6.28
  • MySQL version: 5.1.41
  • PHP version: 5.2.10
a way to fix incorrect country/state data
June 25, 2012, 10:58:10 am
Whenever I do an import, some contacts end up with foreign countries and cities in the address, even though the zip code was correctly imported. Is there any way to automate fixing this data?

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: a way to fix incorrect country/state data
June 25, 2012, 11:07:20 am
Hi Dave,

I'm a little bit confused.  In the subject you say "incorrect country/state", but in the post, you say "countries and cities".  Which is it?  I'm guessing the former - I'm not sure I can think of a way you'd end up with incorrect cities.

I think more data would be helpful toward solving your problem.  Could you post the relevant parts of a record that import incorrectly?

As to automate fixing the data - I think it would be hard to say without seeing an example.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

daveatkins

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
  • CiviCRM version: 4.1.6
  • CMS version: Drupal 6.28
  • MySQL version: 5.1.41
  • PHP version: 5.2.10
Re: a way to fix incorrect country/state data
June 25, 2012, 11:46:42 am
sorry, yes, I mean the country and state are wrong. The city and zip code are correct, so it is easy to fix the problem after the fact...but not when you have thousands of records and are not sure how long this problem has been going on.

Here is an import I just did. The import data (sanitized with xxx to replace identifiable stuff):

"Company","Address","City","State","ZIP Code","Country","Phone","Fax","Title","First Name","Last Name","E-mail Login"

"xxx","1234 xxx","Jackson","TN","38302-0700","","xxx-xxx-xxxx","xxx-xxx-xxxx","Manager","John","Smith",""

The resulting imported record has John Smith living in:
City, State, Postal, Country
Jackson, Tājūrā' wa an Nawāhī al Arbāh, 38302-0700, Libyan Arab Jamahiriya



« Last Edit: June 25, 2012, 11:53:58 am by daveatkins »

daveatkins

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
  • CiviCRM version: 4.1.6
  • CMS version: Drupal 6.28
  • MySQL version: 5.1.41
  • PHP version: 5.2.10
Re: a way to fix incorrect country/state data
June 25, 2012, 11:55:19 am
the database I am importing from...I think the country field was typically not filled out unless it was non-us, so that is why the import data does not include a country code reliably

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: a way to fix incorrect country/state data
June 25, 2012, 01:10:29 pm

i suspect your easiest option is to delete all the newly imported contacts. Add a country field to each line of the import file and repeat the import process

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

daveatkins

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
  • CiviCRM version: 4.1.6
  • CMS version: Drupal 6.28
  • MySQL version: 5.1.41
  • PHP version: 5.2.10
Re: a way to fix incorrect country/state data
June 25, 2012, 01:25:52 pm
thanks...that is part of my workflow now but I have a lot of previously imported records where I did not notice this problem happening. I think I can work something out with some database queries and links to edit the records

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: a way to fix incorrect country/state data
June 25, 2012, 02:03:44 pm
Ah, I see now.  I don't typically run into this problem because I start by not enabling any countries (besides US) and then enabling them selectively based on the errors I get during import.  In your case, Civi saw the "TN" for state, didn't know the country, and picked the first state it had with a "TN".

Do you have an easy way of identifying these records?  You can fix the country by exporting the IDs, opening it in LibreOffice Calc (or Excel) and adding a second column "Country" and filling it with "United States", then doing an "Update" import.  However, I can't think of an easy way to fix the state - unless you still have the original import records, and can correlate the "broken" contacts with the original import?  If so, just reimport the matching field (probably external identifier or e-mail address), the state, and the country.  Use an "update" import.  And of course, test on a dev server :)
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • a way to fix incorrect country/state data

This forum was archived on 2017-11-26.