Add Prefix or Suffix to attribute names in joined dataset?

tmyers
tmyers New Altair Community Member
edited November 2024 in Community Q&A
Hi. I am joining 2 datasets into a single dataset. As each dataset has many attributes with odd names, I would like to distinguish in my final joined dataset the source of each attribute. I would like to add a prefix onto the attribute names in my final joined dataset identifying the original source of the attribute (for example, datasetA_att1, datasetB_att2, and so on).

Is there a way to do this without having to rename each individual attribute? My final joined datsaset has over 2000 attributes. :(

Thanks in advance for any advice-

Tim
Tagged:

Answers

  • mikeyharms
    mikeyharms New Altair Community Member
    Hi Tim,

    This is very doable. You can use the Rename by Replacing operators pre-join for both datasets.

    attribute filter type = all (default anyway)
    replace what = (.*.)
    replace by = $1_set1 or $1_set2

    - The $1 takes everything that is captured in the parens in replace what.
    - .*. this is regular expression that says any character (.) any length (*)
  • tmyers
    tmyers New Altair Community Member
    Mikey, you're the best, works perfectly. Thank you so much!
  • mikeyharms
    mikeyharms New Altair Community Member
    Glad it helped.