Skip to main content

Hello, I’m trying to dynamically add a suffix to selected attributes using BulkAttributeRenamer.  I want the suffix to be the day the script is run and expressed in YearMonthDay.

Example: the attribute is “addresses_count_“ and using the BulkAttributeRenamer and running the script on the 24.10.2024 I want it to be “addresses_count_20241024”.

I tried using UserParameters. The first parameter I made was a Text Type Parameter where before the script is run the User needs to input by hand the Date. It has a few flaws. For example, the user may enter the wrong date, the date is not entered automatically by the script and will not always be processed correctly by BulkAttributeRenamer.

The second UserParameters I made and think it is the right way to do it is a Scripted Type Parameter. Below you can see what I made.

I have not been able to get this to work using the BulkAttributeRenamer. Even when I select the string to be a UserParameter it doesn't seem to add and generate a correct date string.

Maybe I wrote the code wrong, or there are other problems I’m not aware of.

I would really appreciate your help in solving this and maybe suggest a better solution. The main reason I need it somehow to work is, I’m generating in another script using SQLExecutor new columns with the Date I run the script.

In the future, I need column names with dates to compare specific days to each other and calculate the change in specific regions.

I’m using FME Form 2023.2.0.0 (Build 23764). Any insight or advice?

Have you validated that the parameter is actually getting created correctly with a parameter fetcher and inspecting the result? It looks like you have n rather than an m in the dateformat


Have you validated that the parameter is actually getting created correctly with a parameter fetcher and inspecting the result? It looks like you have n rather than an m in the dateformat

Yes I inspected it, and it creates a good date. I double checked and in the date format I have an %m

 


If you look at the feature with the feature inspector do you see the attributes there, i.e. they are there but unexposed?


If you look at the feature with the feature inspector do you see the attributes there, i.e. they are there but unexposed?

It looks like they are there but unexposed.

Another thing is that it made Values from every field <missing> but it looks like it shows them in Unexposed Attributes.

I tried write the data to Excel but even then it shows missing Values.

 


Why use a parameter at all? Add a DateTimeStamper just before the BulkAttributeRenamer, set the Type to Date, and you’re done. No need for python scripting or anything…

 

Although I don’t think it is a good idea to create a datamodel that relies on table- and columnnames to identify a part of the information. Instead you should just add columns for begin- and enddates and -times, that way your datamodel does not need to change. It’s far better to have one table with maybe a 100 million rows or possibly a billion rows which is clearly defined and known, than have 365 tables and/or columns for a single year, all containing the same data bit with entirely different names. In the first case you can even use standard tools to display and analyse the data, in the second case that will be much harder. So I would seriously reconsider my approach.


Similar thoughts.  Don't use dynamic field names unless you want the data users to hate you.  It is so much harder to script or design queries and reports on data stored like this and I have sworn and cursed at any data provider who has given me fields with the dates embedded into field names that turned what otherwise would have been a simple query design into a painful process.

Use a separate metadata table that in each row lists the data table name and date written, or as @s.jager suggests, put this metadata date in its own field in the main table.


Reply