Skip to main content
Question

How to create a private parameter so that when features are written they have the date and time along with the name of the file, also with some attribute value like STATE.

  • September 17, 2021
  • 2 replies
  • 21 views

bhavyagandhi
Contributor
Forum|alt.badge.img+1

Suppose there are some features in different state, I want those features to be written like that: ABC_STATENAME_DATETIME.xls.,, so that all the features for a particular state are written in a separate file with datetime and all features in other state are written in other file like that. I tried using attributevalue and datetimeformat in feature writer but it was taking too much time because datetime was being calculated for million for features that were coming in. I just want it to be a 1 file with a final timestamp, not multiple. Any easy/fast way?

2 replies

nielsgerrits
VIP

One way to do this is to create a (Python) scripted parameter, something like:

import datetime
datetime.datetime.now()

And use that in the fanout. All the data will get the datetime from the start of the run.


david_r
Evangelist
  • September 21, 2021
nielsgerrits wrote:

One way to do this is to create a (Python) scripted parameter, something like:

import datetime
datetime.datetime.now()

And use that in the fanout. All the data will get the datetime from the start of the run.

I agree about the solution (I use it myself quite often), but you'll have to format the output from now() to get a string that FME will accept as a return value. Example:

import datetime
n = datetime.datetime.now()
return n.strftime('%Y%m%d')  # Example: '20210921'

Incidentally, the formatting codes used by strftime() are identical to the DateTimeConverter, so it's easy to adapt to whatever you need.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings