Dynamic Column name
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Dear All,
I have the following use case.
I have an input file, in this input I have a section somewhere in the file where I can find some values which I would like to use later as column name. I say " somewhere" because it can be anywhere BETWEEN the number (14) after [VARBLE INFO] (they number can be 14, 13 or other number as well - it always depends on how many column names we have) and [HISTORY DATA].
Example for 14 parameters:
[VARBLE INFO]
14
Pressure MPa
Temperature oC
ShearStress MPa
ShearRate 1/sec
u-Velocity cm/sec
v-Velocity cm/sec
w-Velocity cm/sec
FlowRate cc/sec
Density g/cm3
Conversion %
Scorch_Index -
Viscosity Poise
ViscousHeat J
ReactiveHeat J
[HISTORY DATA]
Example for 13 parameters:
[VARBLE INFO]
13
Pressure MPa
Temperature oC
ShearStress MPa
ShearRate 1/sec
u-Velocity cm/sec
v-Velocity cm/sec
w-Velocity cm/sec
FlowRate cc/sec
Density g/cm3
Conversion %
Viscosity Poise
ViscousHeat J
ReactiveHeat J
[HISTORY DATA]
It can happen that next time I will have 15 parameters which I need to use later as column name.
Currently, I have 2 workflows 1 workflow for 13 parameters and an other workflow for 14 parameters but I would like to make this more dynamic.
Currently, in the workflow with 13 parameters I rename the columns manually with the Select tool.
As I feel, I need to solve 2 issue:
1. Get the needed column names from the tool --> after the number after [VARBLE INFO] and before [HISTORY DATA].
2. Use this columns names in the Renaming of the Columns dynamically.
Could you please help me, how can I solve this?
Thanks, Dóra
Solved! Go to Solution.
- Labels:
- Preparation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @bakaidora
One way of doing this is using the dynamic rename tool with the proper configuration. Take a look at the attached example, i think you can adapt it to your situation.
1)Original Headers
2)List of correct headers (must be ordered by the same sequence than 1)
3)After the dynamic rename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Sample data would be helpful. For example, I don't know how your incoming fields will be labeled.
Nonetheless, I took a stab it. It's not elegant but it works.
I created a list of field names for 13 and 14 field incoming scenarios.
The workflow counts the number of incoming fields and matches the total to the appropriate scenario and renames the fields.
I left it off, but I was also playing with a way to dynamically change the field type using dynamic select and multi-field tools.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @bakaidora
Here's a dynamic solution that will adapt to any number of columns
On the bottom path, the Muilt-Row tools flags the rows from the header file that we want to keep. the others are removed by the filter tool. The Formula tools adds the brackets around the units and the rows are sequentially number by the Record ID tool. The Dynamic Rename uses positional rename to rename the columns in the data file.
This will work for any number of columns as long as the data file matches the header file. I've include a sample with 13 columns as well for you to try.
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Dear @danilang
this is almost what I expect, but unfortunately, I have "\d+" after the [SENSOR INFO], as well.
Currently, the workflow is setting '1' on the Keep from row nr. 8.
Thanks so much for helping.
Dóra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
dear @hellyars,
I am not able to check your solution because of my Alteryx version.
"This workflow was created by a more recent version of Alteryx, and may contain tools or functionality not present in this version. Alteryx does not support using an earlier version of Alteryx to open a workflow created with a newer version. For best results, download the latest version of Alteryx."
Unfortunately, this newer version is not available at my company.
Thanks,
Dóra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Dear @Felipe_Ribeir0 ,
the solution what you mentioned is good if the cells what I am searching for are in a fixed place and the number is fixed as well.
But as I mentioned it is changing. Sometimes it starting in row 14 sometimes in row 15 and so on.
And sometimes I have 12 values which I need to use later as a column but in other case this is 13, in a third case this is 14.
Thanks, Dóra
