Skip to main content
Solved

Bulk Rename Attributes with Original Name plus the First Row

  • May 14, 2020
  • 4 replies
  • 197 views

Forum|alt.badge.img+2

Can FME do a bulk rename of all attributes to combine the original name and the first row. See picture for example. The left side is the input. The right side is the desired output.

Best answer by erik_jan

After reading the spreadsheet without field names (defaulting to the column names A and B), this workflow got me the right fields and values:

Sample the first to lines to create the field names.

Aggregate those to have the field names combined with the _.

Copy the names into new attributes.

Merge the new names on each data row.

Use an attribute creator to create the new fields with the right values.

 

Hope this helps.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • Best Answer
  • May 14, 2020

After reading the spreadsheet without field names (defaulting to the column names A and B), this workflow got me the right fields and values:

Sample the first to lines to create the field names.

Aggregate those to have the field names combined with the _.

Copy the names into new attributes.

Merge the new names on each data row.

Use an attribute creator to create the new fields with the right values.

 

Hope this helps.


Forum|alt.badge.img+2
  • Author
  • 11 replies
  • May 14, 2020

After reading the spreadsheet without field names (defaulting to the column names A and B), this workflow got me the right fields and values:

Sample the first to lines to create the field names.

Aggregate those to have the field names combined with the _.

Copy the names into new attributes.

Merge the new names on each data row.

Use an attribute creator to create the new fields with the right values.

 

Hope this helps.

Your workbench does exactly what I asked. However, I should have mentioned that I have several (over 200) fields in the table and the solution above is just as time consuming at manually renaming all the fields.


debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • May 15, 2020

Hi @excel_zm

You can try creating a lookup table and using this lookup table with the SchemaMapper to map the attribute names. You will have to create the lookup table first before setting up the SchemaMapper so you may want to separate creating the lookup table into another workspace.

Workbench won’t display these mapped attributes automatically. Since you mentioned you have many attributes, it may be easiest to skip exposing these attributes and use the SchemaSetter with a dynamic writer to write your output.

I have attached a workspace demonstrating the two steps mentioned above. schemamapperattributename.fmwt


debbiatsafe
Safer
Forum|alt.badge.img+21
  • Safer
  • 648 replies
  • May 15, 2020

Hi @excel_zm

You can try creating a lookup table and using this lookup table with the SchemaMapper to map the attribute names. You will have to create the lookup table first before setting up the SchemaMapper so you may want to separate creating the lookup table into another workspace.

Workbench won’t display these mapped attributes automatically. Since you mentioned you have many attributes, it may be easiest to skip exposing these attributes and use the SchemaSetter with a dynamic writer to write your output.

I have attached a workspace demonstrating the two steps mentioned above. schemamapperattributename.fmwt

Actually, if your destination format is Excel or CSV, you can also not write column names after aggregating the two header rows which should give the desired output. Much simpler than using a dynamic schema but only applicable to formats that allow not writing field names.

merge2headerrowsforexcel.fmwt