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) »
  • need a simpler way to import email lists
Pages: [1]

Author Topic: need a simpler way to import email lists  (Read 2299 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
need a simpler way to import email lists
March 08, 2013, 07:54:32 am
We are transitioning from using Constant Contact for our mailings and this has exposed one of the more annoying oversights in the design of CiviCRM. The way I import a mailing list is to create a text file of email addresses, then import contacts set to fill duplicates and assign to a new group.

It is critical to check off the right boxes here and not include additional fields; otherwise you will create a mess of duplicate records that must be cleaned. I've also learned from experience not to include extra fields because special characters like non-English text e-accent/e-grave/etc. will crash the import with server errors. Even simplified like this, I often get cryptic non-recoverable system errors that require breaking the input file up into chunks and doing a trial and error import. So this is not a task that can be delegated to users; it has to be done by the administrator.

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: need a simpler way to import email lists
March 08, 2013, 08:08:43 am
Agreed that the process can be better!  Maybe we can start the conversation here for a) best practices, and b) room for improvement?

A best practice I generally employ is to ALWAYS tag imported contacts, so I can easily roll them back.  Of course, this can get messy if you're creating contacts via relationships, so even that's not perfect.  I would love an ability to auto-tag the most recent import.

Also, I always dump the database before running an import - so I can roll back with a single command if need be.  Of course, this requires no one be using the database at the time.

Anyway - I think the issue of crashing on non-English characters might have to do with your server's character encoding.  I know I've had problems on some servers, and not on others.  What's your server's character encoding?  And what's the character encoding of the text files you're using?  If you first import the text file into a SQL database and do an import via SQL, does the problem go away?
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: need a simpler way to import email lists
March 08, 2013, 09:31:32 am
Hi,

Import is a pain and civi could handle stuff better, but IMO, most of the issue is in the source itself (eg. one single column containing both first and last name, or name of organisation, or...) badly encoded emails...

For your encoding, your problem is that somehow the file isn't unicode utf8 encoded, if you have it the right format, the encoding will work fine.

They are a few things that would improve the process:
- being able to automatically set a source (in the source field)
- handling errors as warning (eg if the country you import doesn't exist, create the record anyway without the country instead of skipping it completely)
- making easier to rollback. That one is tricky to implement probably
- making errors easier to process, the csv to download would be better handled as a html table, ideally with an option to automatically correct and import line by line
- being able to automatically put some values on the related contact, eg adding the website on the current employer rather than the user, or create the address on the household and share it with the contact you import
- being able to import a column with several tags or groups

But at the end of the day, as long as I have a few k contacts to import, I tend to write import code, that handle better missing values and custom matching rules...
X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: need a simpler way to import email lists
March 09, 2013, 05:21:52 pm
What I would like to see is an alternative to import. I am not importing contacts; I am attempting to assign existing contacts to a group. The typical process is to do an export of contacts from various groups, cull the list by hand, then re-import the cleaned list and assign to a group to be used for mass emailing.

In an ideal world, perhaps this could be done through advanced search and smart groups...but we really need to go over the list by hand. Users do not trust such automations.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: need a simpler way to import email lists
March 09, 2013, 07:26:05 pm
if you include the Internal ID in your export - then do your culling - then import a file that only has the (remaining) Internal IDs (ie the csv has one column only for the Internal ID) - and add those contacts to a group - where do you hit problems?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

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: need a simpler way to import email lists
March 10, 2013, 11:40:16 am
thanks; that is a great idea. That will also cure the problem of inadvertently importing  a second, duplicate "home" vs "work" email address. I had been using email address as the identifier for these operations

Detlev

  • I post occasionally
  • **
  • Posts: 68
  • Karma: 2
    • Software für Engagierte e.V.
  • CiviCRM version: 4.5
  • CMS version: Drupal
Re: need a simpler way to import email lists
July 20, 2013, 07:44:31 am
Just another idea that might help:

The problem: You want to add a number of e-mail addresses stored in a csv file, to a certain civicrm group (e.g. Group-ID=42), without using any sql stuff which is not available for a normal user.

The solution:
Step 1: Add a custom field named "Temporary-GroupID", and define it as searchable.
Step 2: Edit the csv file, add a column which is all filled with the value of "42" (same as your group-ID!)
Step 3: Import the csv file (only import e-mail address and the column with the group-ID, use a dedupe rule with e-mail only).
Step 4: Within extended search, look up all contacts with Temporary-GroupID=42
Step 5: Action: Add all matched contacts to your Group. Voilà!

Greetings, Detlev

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: need a simpler way to import email lists
July 20, 2013, 07:55:36 am
Hi Detlev,

I just read over your suggestion - is there an advantage to this approach over simply specifying that all contacts in that import should be added to a group?

I guess one advantage I see is that the GUI import only allows you to add someone to one group per import - this approach would support multiple groups.

Using Xavier's CLI import tool is my preferred way of handling that situation - but that requires comfort with the command line.  I saw it suggested that CSV should be a native supported input/output format of the API (like XML and JSON are now) to make this sort of thing easier...
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: need a simpler way to import email lists
July 20, 2013, 08:21:15 am
Hi,

One problem is that csv is a standard format, but then you have many formats named csv that have different separator (semi column or tab) and different charset based on which version of excel you use (fun fact, Microsoft has decided that the comma in the us version of excel for csv would be more suitably replaced by a semi-column in the french version because whatever).

I have moved away from that for the normal export, for the import, not sure how long it would take to create a new parser (like csv or sql today)

But in general, complex imports have complex rules (if the first name is empty then it means it's an organisation, use the address both for the individual and her employer, if the country is missing but not the street name put US by default unless the phone number starts with a +49 in that case it's germany...)

That and the ability to re-run the script without having to jump through all the wizard steps of the UI makes it a better option to go custom import code IMO. Checkout the work of eileen using the migrate module if you are using drupal, seems an interesting approach

http://fuzion.co.nz/content/migrate-2-civicrm-api-3-civimigrate
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: need a simpler way to import email lists
July 20, 2013, 08:31:01 am
Hi Xavier,

I'm sorry to hear you're moving away from your CLI tool - I just submitted some enhancements for it!

At CiviCon North America 2012, I went to a workshop run by Young-Jin at Emphanos together with Eileen, each discussing their methodology.  It was hands-down the most useful Civi workshop I ever attended - I ended up adopting an approach closer to Young-Jin's, but if you do a lot of importing, definitely watch the video!

Essentially - I used to write custom scripts, but now I handle the complex import/export rules using a dedicated ETL tool.  Young-Jin and I both use Pentaho Kettle, but it's a bit clunky - if I had to start over I might try a different tool like Talend.  However, I now have a bunch of reusable pieces - and I find it much easier to reuse parts of my ETL transformations than I do to reuse my import code.  I also don't need to write code for a lot of common transformations, though writing a bit of code is often unavoidable, or just simpler (Kettle lets you use Javascript and/or SQL).

Once I have a complete set of transformations, I have a second ETL job that uploads my transformed .csv files to the server via SFTP, and sends commands over SSH to run your import tool, capture the output back to my local machine, and run another transformation that parses the errors.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: need a simpler way to import email lists
July 20, 2013, 10:14:21 am
Hey sounds like a great solution. Wanna come to civicon london and present it?  (that's not that far)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: need a simpler way to import email lists
July 22, 2013, 09:18:44 am
I think the video of Young-Jin and Eileen's talk is still the gold standard - maybe once I've made enough innovations to justify a a follow-up!  Even then...5600km is a bit of a ways to give a 1 hour talk, much as I'd love to meet the European Civi community.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: need a simpler way to import email lists
July 22, 2013, 09:25:54 am
Then come to the sprint as well. See already more worthwhile ;)
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • need a simpler way to import email lists

This forum was archived on 2017-11-26.