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.

Files: 
CommentFileSizeAuthor
#7 multiple_replace-1525540-7.patch1.66 KBLendude
PASSED: [[SimpleTest]]: [MySQL] 1,508 pass(es).
[ View ]
feeds_tamper-multiple_replace.patch1.6 KBfranz

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
StatusFileSize
new1.66 KB
PASSED: [[SimpleTest]]: [MySQL] 1,508 pass(es).
[ View ]

@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.