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) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • How do I update > 1000 invalid records
Pages: [1]

Author Topic: How do I update > 1000 invalid records  (Read 406 times)

grobinson

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 4.2.7
  • CMS version: Nil
  • MySQL version: Dunno
  • PHP version: Dunno
How do I update > 1000 invalid records
November 30, 2014, 09:11:26 pm
I used an email validator service to find invalid email addresses in my CiviCRM database. Problem is I have over 1000.

1. Option 1. Normally you would flag invalid email addreses as ON HOLD, but short of opening all 1000 records, I cannot find a batdch method of marking these records ON HOLD

2. Option 2. I thought of using import to replave the bad email addresses with a nul. But CiviCRM will overwrite an existing value with a NUL value

Help please. I do not want to update over 1000 records by hand!

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: How do I update > 1000 invalid records
December 02, 2014, 11:19:42 pm
If you you're comfortable with spreadsheet formulas and a tiny bit of SQL:

1. Copy the 1000 email addresses into a new spreadsheet (column A)
2. In column B, use a formula and apply it to all the emails. (example for row 1 below)

Code: [Select]
="update civicrm_email set on_hold = 1 where email = '" & A1 & "';"

3. Observe that column B  should now display, e.g.

Code: [Select]
update civicrm_email set on_hold = 1 where email = 'user@example.org';

4. Copy the text from column B
5. Paste the text into your favorite SQL tool and execute it.

--

If you're comfortable on the Unix command-line, then you might do something like:

1. Copy the 1000 email addresses into a flat text file ("invalid-emails.txt")

2. Run:

Code: [Select]
cat invalid-emails.txt | while read email ; do echo "UPDATE civicrm_email SET on_hold = 1 WHERE email = '$email';" ; done | mysql -u USERNAME -p -h HOSTNAME DBNAME

# (USERNAME, HOSTNAME, DBNAME should be adapted to your particular system; you can usually figure out these values by searching civicrm.settings.php for the "DSN")

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • How do I update > 1000 invalid records

This forum was archived on 2017-11-26.