Scenario: I read 1 or more CSV files, process them and write data out to a File Geodatabase (FGDB) point layer. Currently I'm fanning out on fme_basename of the CSV file. However my overall workflow might be more efficient if I write out to a single FGDB per run, regardless of how many input CSVs there are. In order to avoid overwriting an existing FGDB that may not have been cleaned up by a previous run, I thought of using the Date/Time the Workspace was run as the FGDB name. But how to do this? DateTimeNow as Fanout Expression results in many FGDBs! TimeStamping the first feature then applying that value to every subsequent feature seems over the top, as does using a WorkspaceRunner to set the output file name.
Hi @tim_wood
The difference between CSV and FGDB is that the first one - for a fanout - multiple files are generated within the directory you linked to the writer.
For a FGDB, you 'link' the writer to a File geodatabase and not to a directory. Every 'filename' will result in a new layer within the FGDB and not in a new FGDB. If you want to use the datetime in the FGDB, you should link the 'directory to write to' to a parameter having the datetime included.
This question might help you: https://knowledge.safe.com/questions/41684/set-writer-output-folder-from-attribute-value.html?childToView=41685#answer-41685
Hi @tim_wood
The difference between CSV and FGDB is that the first one - for a fanout - multiple files are generated within the directory you linked to the writer.
For a FGDB, you 'link' the writer to a File geodatabase and not to a directory. Every 'filename' will result in a new layer within the FGDB and not in a new FGDB. If you want to use the datetime in the FGDB, you should link the 'directory to write to' to a parameter having the datetime included.
This question might help you: https://knowledge.safe.com/questions/41684/set-writer-output-folder-from-attribute-value.html?childToView=41685#answer-41685
So if I read in A.csv, B.csv, C.csv and expose fme_basename, and set a Fanout Expression of @Value(fme_basename) on my FGDB Writer in the Navigator pane, I will get A.gdb, B.gdb, C.gdb.
That's been the case for me in FME 2016.1 and FME 2017.0.
You could use a parameter? From memory the default value of a date/time parameter is the current time. Then set the feature class to the parameter value
I often use a Python scripted private parameter for this. Example:
from datetime import datetime
current_date = datetime.now().strftime('%Y%m%d')
return 'myFGDB_%s.gdb' % current_date
Which will return something that you can use for the fanout, e.g.
myFGDB_20170327.gdb
You could use a parameter? From memory the default value of a date/time parameter is the current time. Then set the feature class to the parameter value