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) »
  • Wrong default country on import?
Pages: 1 [2]

Author Topic: Wrong default country on import?  (Read 5538 times)

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: Wrong default country on import?
November 05, 2009, 12:34:14 pm

can you apply this patch and see if it fixes things:

Code: [Select]
svn diff CRM/Import/Parser/Contact.php
Index: CRM/Import/Parser/Contact.php
===================================================================
--- CRM/Import/Parser/Contact.php       (revision 24884)
+++ CRM/Import/Parser/Contact.php       (working copy)
@@ -1015,6 +1015,9 @@
      */
     public function checkGender( $gender ) {
         $gender     = trim( $gender, '.'  );
+        if ( empty( $gender ) ) {
+            return false;
+        }
         $allGenders = CRM_Core_PseudoConstant::gender( );
         foreach( $allGenders as $key => $value ) {
             if ( strlen( $gender ) > strlen( $value ) ) {

thanx

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

cwgng

  • Guest
Re: Wrong default country on import?
November 05, 2009, 05:03:03 pm
yep, that does it.
thanks!

a more general question: can i expect that this tiny change will be in future releases of CiviCRM, or will i need to reapply this patch if i'm hoping to import data which may have a blank entry in the gender field?

even more generally: before importing i couldn't find a "spec" anywhere listing how CiviCRM wanted its imported fields to be formatted. is there one? it took trial-and-error to figure out, for instance, that i have to strip trailing/appended time information from date fields before i can import them. (or maybe this stuff should be obvious and i'm just not in the right frame of mind.)

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Wrong default country on import?
November 05, 2009, 09:51:39 pm
Quote
a more general question: can i expect that this tiny change will be in future releases of CiviCRM, or will i need to reapply this patch if i'm hoping to import data which may have a blank entry in the gender field?
Code will be part of next stable release.

Quote
even more generally: before importing i couldn't find a "spec" anywhere listing how CiviCRM wanted its imported fields to be formatted. is there one? it took trial-and-error to figure out
I would like :
1. first check civicrm export functionality for same set of fields.
2. then try to import fields with same format.

hope this help

kiran
You Are Designed To Choose... Defined By Choice.

cwgng

  • Guest
Re: Wrong default country on import?
November 06, 2009, 08:41:46 am
thanks for your answers! i really appreciate how quickly everyone on this forum responds!

separately, i may spend some time in the future adding to the wiki documentation on importing data (at http://wiki.civicrm.org/confluence/display/CRMDOC/Importing+Data ) because i found it somewhat lacking.

alphageekboy

  • I’m new here
  • *
  • Posts: 11
  • Karma: 1
  • Web Developer
    • Alpha Geek Tech, LLC
Re: Wrong default country on import?
August 13, 2010, 10:22:52 pm
I actually saw similar results in my import that was done in 3.1.5.  However, I didn't catch the error until 3.2.1.  We noticed some strange states/provinces coming up with US cities in the AutoLookup on the contact search.  Fortunately, I found this post relatively quick and it pointed me in the right direction.

I haven't had a chance to look at the import, but it appears this error still existed in 3.1.5 as the country id was imported correctly.  I was able to resolve this with the following query:

Code: [Select]
UPDATE civicrm_address ca
INNER JOIN civicrm_state_province old_state ON old_state.id = ca.state_province_id
INNER JOIN civicrm_state_province new_state ON new_state.abbreviation = old_state.abbreviation AND ca.country_id = new_state.country_id
SET ca.state_province_id = new_state.id

I'm hoping this has been fixed in later versions, but at least I didn't have to reimport my 6000+ contacts.
Tracy C. Smith
Chief Technologist & Founder

Alpha Geek  Tech, LLC
p: 831.706.2187
http://alphageektech.net
skype/aol: tracycsmith
t: alphageektech

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Wrong default country on import?

This forum was archived on 2017-11-26.