I needed to apply a big mapping of 111 values with Find & Replace. I found it useful to have a single tamper that gets a list of all replacements. This patch is not yet good to be committed, needs to be tested and improved, but might be helpful to some people.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xaqrox’s picture

Status: Needs review » Reviewed & tested by the community

Patch above worked perfectly for me. Thanks!

xaqrox’s picture

Status: Reviewed & tested by the community » Needs work

So after further testing I ran into a problem. I'm using this tamper on a CSV user import, mapping values from several columns onto a taxonomy field, like this:

  1. A Rewrite tamper to pull values from the 24 preceding columns and this one into a single string, comma separated.
  2. This Find and replace multiple tamper, to replace deprecated term names with newer ones in the string. I do this here as opposed to after the Explode because some old terms map to two new ones. (i.e. "term,term,this-one,term" becomes "term,term,that,one,term")
  3. An Explode tamper on commas.
  4. A Unique tamper, in case the find and replace created duplicates.

As expected, the new users get the updated taxonomy terms. However, terms matching the "source" half of the find & replace multiple pairs are being created too. Haven't had the time to track this down, and it's a one-time import so I can deal with just deleting those extra terms, but this feature isn't quite ready.

irgnet’s picture

How to stop replacing after first replace.
If i have in list

Beauty|Health and Beauty
Health|Health and Beauty

The result is

Health and Beauty and Beauty.

franz’s picture

That seems out of scope for current implementation. Why don't you try:

Beauty|_TEMPORARY1_
Health|Health and Beauty
_TEMPORARY1_|Health and Beauty

A bit skechy, but I think it works.

irgnet’s picture

Hi,
after update feeds and feed tamper modules this was stopped working

I've got this error when i try to edit find_replace_multiple into UI

Fatal error: Function name must be a string in ..\sites\all\modules\feeds_tamper\feeds_tamper_ui\feeds_tamper_ui.admin.inc on line 459

And

Fatal error: Function name must be a string in ..\sites\all\modules\feeds_tamper\feeds_tamper.module on line 68

when 9 try to import

pauldolphin’s picture

Issue summary: View changes

First off....A big thank you to @twistor for your hard work and @franz for posting this patch.

Came across this patch while looking for a way to tame all of the find/replace plugins we've needed to put in place with some pretty dirty data provided by a manufacturer that we needed to clean up.

The find/replace plugin is easy enough...the trouble comes when you have more than a few find/replace plugins in place on a given field. The UI just turns into a mess. This plugin looked like the solution...but it isn't playing nice with the latest dev version for feed_tamper.

Anyone out there with mightier coding skills that may be able to help get this plugin working again? Anyone else out there that is having success with this plugin?

Lendude’s picture

Status: Needs work » Needs review
FileSize
1.66 KB

@pauldolphin what wasn't playing nice for you?

Did a small modification to get it running for me with the current version of dev 7.x-1.x. The 'target' needed to be trim()'ed or it would leave a \r and then never find a match so nothing would get replaced.
Other then that it works great so far.

Updated patch added.

thePanz’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #7 works fine, thanks!

NWOM’s picture

#7 worked amazingly. Thank you!

dayures’s picture

Please, find attached another version of the plugin. A checkbox to select if the you want a full comparison. For example:

Original text:
agricultural area

Replace pairs:
area|new area
agricultural area|updated agricultural area

Processed text (full comparison NOT selected)
agricultural new area

Processed text (full comparison selected)
updated agricultural area

dayures’s picture

Please, find attached another version of the plugin. A checkbox to select if the you want a full comparison. For example:

Original text:
agricultural area

Replace pairs:
area|new area
agricultural area|updated agricultural area

Processed text (full comparison NOT selected)
agricultural new area

Processed text (full comparison selected)
updated agricultural area

The last submitted patch, 10: feeds_tamper-multiple_replace.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 11: feeds_tamper-multiple_replace-1525540-11.patch, failed testing.

tyler-durden’s picture

Has any process been made on this? I need to find/replace on about 100 or so terms on multiple feeds. This would be impossible to do on an in individual plugin line basis.

I'm not a programmer, but can do some testing. I see the last few patches have failed testing?

NWOM’s picture

#7 still applies cleanly to newest dev. I did not test #11 due to it failing the tests currently.

MegaChriz’s picture

Issue tags: +Needs tests

@NWOM
I think that #11 failed at the time, because branch tests were failing. Indirectly this was caused by Drupal Core adding the permission "administer fields" in a minor version.

Anyway, a new plugin needs tests.