Question

Change Columnnames based on first value

  • 27 January 2022
  • 3 replies
  • 2 views

Hello i want to change the Columnames based on the first value.

Example:

Column: A

first Value: Dog

newColumname: Animal


3 replies

Userlevel 4
Badge +25

Do you have a list of criteria? I.e. a list of values for column A that would result in it being renamed to Animal.

Do you have a list of criteria? I.e. a list of values for column A that would result in it being renamed to Animal.

the criteria would be the first value. So check all columns if it has "dog" as the first value. If yes then rename the column to Animal.

 

I have two different Date columns so the dates could be same in both columns but in the first row they have different values so i know the column with the 12.03.2020 is Date_A and the other column with 14.02.1990 is Date_B

Userlevel 4
Badge +25

the criteria would be the first value. So check all columns if it has "dog" as the first value. If yes then rename the column to Animal.

 

I have two different Date columns so the dates could be same in both columns but in the first row they have different values so i know the column with the 12.03.2020 is Date_A and the other column with 14.02.1990 is Date_B

Yes, it's possible.

  1. Build a list of all your features (ListBuilder)
  2. Check if the first list element has attribute value "dog" (TestFilter)
  3. If so, explode the list to get your original features back (ListExploder)
  4. Rename the attribute (AttributeRenamer)

Screenshot 2022-01-27 at 11.34.06I've attached this as a template. Note that if you want to support different animals you should edit the TestFilter.

 

Reply