The simplest way I know is to create the attributes by a python caller:
import fmeobjects def processFeature(feature): name = feature.getAttribute('FieldName') value = feature.getAttribute('FieldValue') feature.setAttribute(name, value)
If you know all possible field names, then you can create them in advance to be able to use them in subsequent transformers.
Hi,
The
RecordBuilder custom transformer might be available. And also
a similar question is here.
Takashi
The BulkAttributeRenamer can do this (called AttributeExpressionRenamer in earlier versions of FME)
Select the attribute you want to rename, select "Regular Expression Replace" and enter .* if you want to replace the whole name.
Then for the "String" setting select the attribute containing the value you want to use as the name which I guess is Fieldname
Hi Ken,
I didn't know that usage of the BulkAttributeRenamer. After renaming, we can transform input rows to new records using the AttributeAccumulator (Group By: RecordGroup). Thank you for the information.
Takashi
Hi Takashi,
Hi Ken,
it's great to have a working community like this!
This topic helped me very much with my issues.
Now, is it possible to save these auto-generated attribute-names in a writer?
In my case i am using FME 2014. The writer is SQLite.
Thanks in advance.
-Maria
The BulkAttributeRenamer can do this (called AttributeExpressionRenamer in earlier versions of FME)
Select the attribute you want to rename, select "Regular Expression Replace" and enter .* if you want to replace the whole name.
Then for the "String" setting select the attribute containing the value you want to use as the name which I guess is Fieldname
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Hello @ridleyj , would you be able to demonstrate your issue with screenshots perhaps? Just having a bit of a hard time visualizing the issue from your description, apologies! Also, what version of FME are you currently using? Best, Kailin.
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Hi @kailinatsafe
Thank you for looking into my enquiry.
The data, pulled from exposing specific columns in a spreadsheet, then split into two field chunks ktestFilter], looks like this:
BulkAttributeNamer is then employed to (attempt to) take the value of attr_Name_Label and rename the attr_Value field with it:
The output by those settings is identical to the input (no change of field name), but I mixed the REGEX up a little to see if I could get any result and thereby got this:
The workflow is intended to take the new named attribute then pass the chunk through to a recombination procedure to compile it with the other chunks including their renamed attr_Value fields. Overall, it's an inefficient pivot type transformation, but works for the data as supplied!
FME version info:
Edition: FME Desktop Oracle Edition (floating)
Version: FME(R) 2021.0.0.0 (20210305 - Build 21302 - WIN64)
Locale: en_AU
Codepage: windows-1252
Registration Key:
Registration: Licensed (Floating: )
Serial Number:
Customer Number:
Home Folder: C:\\Program Files\\FME\\
Operating System: Microsoft Windows 10 64-bit (Build 19041)
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Hello @ridleyj, if you go to the visual preview window and on the far right beside "Table Name", you should see a "Columns..." button, open this and do you see the appropriate column there?
Alternatively, if you add an AttributeExposer after the BulkAttributeRenamer, are you able to expose the newly named column? Let me know, Kailin.
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Hello @ridleyj , ahh I think we uncovered the issue. Would you please try using this regex expression:
^.*
This should work for you now, but you may have to expose it afterwards still! For some reason ".*" isn't doing whats expected currently. I'll make a ticket to have this fixed. Thanks for bringing this to our attention. Let me know if you still have issues after changing the regex expression. Best, Kailin.
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Thanks for the update @kailinatsafe . I'll give that a try and advise you of the result. Thanks again for looking into this.
Cheers.
Jason.
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
Hi @kailinatsafe
I have run that test as instructed, and can confirm that the "^.*" regex is working as indicated; the result does need to be exposed. Great news, thanks for the workaround.
J.
Hey Safe Team, Takashi
I tried this method and am finding the regex replace is not working when using the attribute value method. The output retains the same names as input, but the value of the "renamed " target field is now "missing". An explicit replacement string works, but that is not useful for the intended automation - is this a known issue with the current bulkAttributeRenamer I wonder?
@ridleyj Thanks for confirming! FMEDESKTOP-12830.