Mass Renaming Columns

Options

Is there any way for me to mass rename columns? Instead of going into the "Select Columns" tile and going down the list 1 by 1 can I copy paste a text file somewhere that will do this? In any other case I would be fine renaming, but right now my dataset has an output of almost 700 columns.

Tagged:

Best Answer

  • MarkSnodgrass
    Answer ✓
    Options

    One option would be for you to select the select columns tile and the tile before and then choose the "copy to clipboard" option and pasted it into a text editor. It is JSON formatted data, so you could add in all your fields in your text editor and then paste it back into Magic ETL. Here is what the select columns tile looks like in a text editor with just a single field added called "name"

    {
                "name": "Select Columns",
                "id": "42981323-1821-44aa-835d-06815d117720",
                "type": "SelectValues",
                "gui": {
                    "x": 252,
                    "y": 108
                },
                "dependsOn": [
                    "e445a86c-6759-445b-a096-b4c5063e6575"
                ],
                "removeByDefault": false,
                "notes": [],
                "fields": [
                    {
                        "name": "name"
                    }
                ]
            }
    

    Hope this helps.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.

Answers

  • MarkSnodgrass
    Answer ✓
    Options

    One option would be for you to select the select columns tile and the tile before and then choose the "copy to clipboard" option and pasted it into a text editor. It is JSON formatted data, so you could add in all your fields in your text editor and then paste it back into Magic ETL. Here is what the select columns tile looks like in a text editor with just a single field added called "name"

    {
                "name": "Select Columns",
                "id": "42981323-1821-44aa-835d-06815d117720",
                "type": "SelectValues",
                "gui": {
                    "x": 252,
                    "y": 108
                },
                "dependsOn": [
                    "e445a86c-6759-445b-a096-b4c5063e6575"
                ],
                "removeByDefault": false,
                "notes": [],
                "fields": [
                    {
                        "name": "name"
                    }
                ]
            }
    

    Hope this helps.

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Jmoreno
    Options

    Wow... just tested this on a small scale (due to there being 700+ columns browser keeps freezing on me anytime I open up that tile lol) and it worked like a charm, thank you... I will comment on here again if I end up needing more help lol @MarkSnodgrass

  • AdamC
    AdamC Member
    Options

    @MarkSnodgrass

    Post from a while back, but I am trying to do the same thing essentially. I am connecting several sheets and there are a lot of overlap between column names. I'd like to add a prefix to each column header so I know which sheet it came from. So something like column 'date' for each sheet would have A_Date, B_ Date, C_ Date. Assuming I am going to need to do each sheet separately in the ETL, but changing in bulk would save me a bunch of time.

    I have two tiles, the inputdata tile and then the select columns tile. In the select columns tile I selected 'all columns' then copied and the two tiles into MS text editor. Looks something like this:

    {"name":"Date"},{"name":"Invoice #"},{"name":"VV#"}

    I am not sure how to tell it to change these names from this point or if I even did that step correctly.

  • MarkSnodgrass
    Options

    Sounds like you are going to want your select columns json data to look like this:

    {"name":"A_Date"},{"name":"A_Invoice #"},{"name":"A_VV#"}

    One easy way to do this in a text editor would be to do a find and replace and replace "name":" with "name":"A_

    This should prefix each of those columns with A_

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Jmoreno
    Jmoreno Member
    Options

    @AdamC To have the syntax appear for the "rename", you need to at least rename one of them before copying.

  • AdamC
    AdamC Member
    Options

    Thanks much. Boy that is for sure finicky, but sure appreciate the help. I don't know much about coding at all so took me a while to figure out what is going on.

    Thanks @MarkSnodgrass @Jmoreno appreciate the help!

    For anyone coming into the thread later down the road like me who is not great at coding this is what I ended up doing:

    • Take the basesheet tile and add select columns tile to the ETL (Don't add any columns to the select columns tile)
    • Select both tiles and 'copy'
    • Past into a text editor
    • At the end of the code you will see "removeByDefault":false,"notes":[],"fields":[ ]}]}
    • Will need to past all your new column names in this format between the [ and ] after "fields". Example: {"name":"Hazardous","rename":"PTR_Hazardous"},
    • Copy all the text and past back into the ETL, it will add two new tiles. Delete the base sheet tile (its blank) and then reconnect your base sheet to the newly created select columns tile. Then can delete the original select columns tile that is also blank.

    Most difficult part was getting all the old and new names into this format to be able to paste it in. I ended up doing it in excel and then adjusting it when I pasted it into the text editor