span8
span4
span8
span4
I am trying to create a workspace that when run will pull the current date into python (either as start up script or python caller) and then pass that date out as a published parameter in FME. I have the following in python:
import datetime
today = datetime.datetime.now()
#print str(today)
print today.strftime("%Y%m%d")
This gives me the date (for today) as 20161103
I want to pass that out as a Published or Private Parameter [Start_Date] to be read in a transformer later in the process.
I will also need to be able to calculate a date two weeks away and pass that as [End_Date].
Hi @jimq66
you can't set parameter value once translation has started. However, rather than a published parameter value you can use an attribute value in your transformer.
If every feature in your workflow goes through TimeStamper, every feature will have e.g. _startdate attribute with the current datetime added to it by the time it reaches the transformer that needs to use the current date.
To calculate 'two weeks from now' you currently have two options:
Please take a look at the screenshot. I will also attach the sample workspace.
Hi jimq66,
You don't need to use a startup script, neither a Python caller. You can initiate a Published/Private parameter with type "Scripted (Python)".
The code I use in my example is:
from time import strftime return strftime("%Y%m%d-%H%M%S")
Python documentation can be found here.
Cellwise raster manipulation by indexing row/col using the Python API 2 Answers
Transfer python dictionnary between 2 Transformers 3 Answers
ArcPy "import" statement tries to perform import action? 5 Answers
Output dictionary key and value pair from PythonCaller 3 Answers
Export vertex pool with python 2 Answers
© 2019 Safe Software Inc | Legal