Solved

Dynamically copy attributes


Badge +22
  • Contributor
  • 1961 replies

I have a set of csvs where the X,Y fields are named differently in each file, but always in the pattern {prefix}LocationX, {prefix}LocationY. The prefix is unrelated to the filename or any other easy way to predict.

 

In order to process all the files through the same workflow, I would like to copy the attributes to _x and _y so the rest of the transformers can reference those attributes irrespective of the original names.

 

Is there a simple way to do so without dropping into python?

icon

Best answer by david_r 7 June 2021, 17:31

View original

4 replies

Userlevel 4

What about the BulkAttributeRenamer with regex renaming?

Userlevel 1
Badge +21

Two bulk attribute renamers using Regular Expression Replace, one for x, one for y. It looks like it should work on dynamic/unexposed attributes

Capture

Badge +22

I forgot the BulkAttributeRenamer has a Keep Original Attributes mode. That will work.

Badge +22

Two bulk attribute renamers using Regular Expression Replace, one for x, one for y. It looks like it should work on dynamic/unexposed attributes

Capture

For even more dynamism, one could have a single BAR wtih the Text to find be .*Location([XY]) and the String be _\\1. The downside to that is the attributes are not exposed on the canvas, but there is a very minor efficiency gain to BAR+attribute exposer compared to 2 BARs.

 

Reply