Solved

Replace key values in a list

  • 11 July 2020
  • 2 replies
  • 14 views

Essentially I want to use an Attribute Value Mapper against a list. I have a csv lookup table of old ID's and new ID's. Then in my workbench I have a json attribute of a configuration file, which I send through a regex string searcher to get a list of all the old ID's in the config. Is there a way to replace all the old values in the list for their looked-up values from the table, so I can then reinsert them in the config? Or should I just hand this step off to python?

 

I have about 20 features going through the workbench and around 60 features in the lookup table. Each json attribute has anywhere from 5-50 matches feeding the list.

 

I've also looked at the List String Replacer but it doesn't allow me to import the lookup table like the attribute value mapper does. I'm not seeing a way of doing this keeping the transformers under a handful.

 

How would y'all approach this problem? Thanks

icon

Best answer by becchr 13 July 2020, 11:24

View original

2 replies

Badge +2

Can you add an example .json and lookup table?

 

Pretty sure you can accomplish this with a DatabaseJoiner, StringReplacer, and DuplicateFilter. You'll end up with a M:M relationship but that can be dwindled down to the correct 1:1 by removing everything that is the same out of the list that didn't change leaving you with the 1 record you changed.

 

Userlevel 3
Badge +16

hi @rqf4v9, maybe some sampledata can be helpful to understand what you're trying to do exactly, but if I understand your question the StringPairReplacer might help you?

By tweaking your CSV a bit you could just copy it in the 'replacement pairs' of the StringPairReplacer and run your configfile through it?

Reply