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) »
  • Importing a comma-separated set of items when an item can itself contain a comma
Pages: [1]

Author Topic: Importing a comma-separated set of items when an item can itself contain a comma  (Read 1081 times)

jsutcliffe

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5
Importing a comma-separated set of items when an item can itself contain a comma
March 28, 2012, 08:49:45 am
Hi,

I'm trying to import a set of contacts. I have a few invalid field errors, but the most irritating to deal with is a list of countries. In my CSV file it's a comma-separated list, which for the most part looks like it will import just fine. However, if I have a country whose name contains a comma, such as "Palestinian Territory, Occupied" (from what I believe is the default set of countries in CiviCRM) that comma-separated list obviously no longer works (e.g. it could read as "Cuba, Palestinian Territory, Occupied, Tuvalu").

Is there a known workaround for this, or have I failed to see a simple solution?

Thanks in advance if anyone can help!

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: Importing a comma-separated set of items when an item can itself contain a comma
March 28, 2012, 09:04:43 am

CSV has a way of escaping comma's. Typically those values are enclosed in double quotes, so your file will look like:

Cuba, "Palestinian Territory, Occupied", Tuvalu

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

jsutcliffe

  • I’m new here
  • *
  • Posts: 3
  • Karma: 0
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5
Re: Importing a comma-separated set of items when an item can itself contain a comma
March 28, 2012, 09:22:55 am
I should have mentioned that I've tried encapsulating the terms that have commas in quotation marks, to no avail. Thanks for the suggestion though.

For example, in the import errors for a field whose contents are

Malawi, "Tanzania, United Republic of", Zambia, Cambodia, Lebanon, "Palestinian Territory, Occupied"

I get

Malawi, Tanzania

ctarascio

  • I post frequently
  • ***
  • Posts: 334
  • Karma: 30
    • American Friends Service Committee
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 6.26
  • MySQL version: 5.5.20
  • PHP version: 5.3.13
Re: Importing a comma-separated set of items when an item can itself contain a comma
March 28, 2012, 10:23:05 am
hi,
try this:

--This is not mandatory but it would be preferable if your csv file did not have quotes around each field but each field should be separated by a comma
--open your csv file in notepad (not excel)
--notepad will surround each country field that has a comma in quotes so if your csv file already had quotes around each field you will probably have to remove the
   extra quotes
--save the file as a csv file from within notepad

this should work for you. if not please post back exact steps you are doing and i will take another look.

cynthia

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Importing a comma-separated set of items when an item can itself contain a comma
March 28, 2012, 02:00:26 pm
I've had a few situations where people have told me they can't export due to commas - but on investigation it turns out they've use quotations marks  (often around nick names) & that it actually the point of failure
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Importing a comma-separated set of items when an item can itself contain a comma

This forum was archived on 2017-11-26.