Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Edit Muliple Fields and Select Only Certain Automatically

GrangerHuntress
5 - Atom

Very new to Alteryx. I know I could pre-process this file in Python, but I want to make this simple for others and keep it within my Alteryx workflow.

 

Let's say I have a file that always comes in the following format.

 

Column names are: C1, C2, C3, C4, C5

All columns are STRINGS

 

But I only want: C2, C3 and C5.

 

I have a second csv file in this format, which is essentially a dictionary to change the names

 

C2,NAME

C3,AGE

C5,LOCATION

 

Going forward I want the following columns ONLY: NAME, AGE LOCATION and I want AGE to be a double.

 

My actual initial field names are much longer and I have approx 95. This trims down to shorter names and about only 30 fields. How do automate this?

3 REPLIES 3
Claje
14 - Magnetar

If the column names in the initial file are consistent (EG C1,C2,...) this is really easy.


If they are not and you have a lot of columns there's an alternative method to my initial proposal.


Proposal 1: initial names follow a pattern


In the Developer Toolset there is a tool called the Dynamic Rename tool which will let you connect in your file input and a second file that has mapping/field renames.

You can configure this to "Take Field Names from Right Input Rows", and to Ignore cases where number of Field Names do not match.

 

Then you can use a Dynamic select tool and filter by formula to filter out anything with a name of C#.


Proposal 2: initial names do not follow a pattern

This method requires a third input which has the column names you expect to get in it.  You should not have any data in this input, just the field names/layout

 

You will still use the Dynamic Rename tool described above to rename your columns.  After this, you will use a Union tool, with your file input (input 1) and your schema input (input 3) connected into it.

You can configure this union tool to "Output Common Subset of Fields" and to not create error messages when fields are missing.

 

This will select down dynamically to your expected field list

AmeliaG
Alteryx
Alteryx

Hi @GrangerHuntress,

 

I've included an example which accomplishes your goal using the 'Dynamic Rename' tool and the 'Select' tool. 

 

Links below to master these tools:

- Tool Mastery Dynamic Rename

- Tool Mastery Select

 

Let me know if you have any questions!

 

Thanks,


Amelia

GrangerHuntress
5 - Atom

Thanks. This will save time as far as renaming goes and makes complete sense. I will like just have to manually select those 40 or so columns I want to keep and change the type for 20 so the first time.

Labels