How to serve folder/files created by SystemCaller (python) in FME Flow?
I am using SystemCaller to run a pyton script (uses conda env) that creates a bunch of files and I am trying to figure out how I can get FME to then read the folder location and serve that to the user as a .zip file. The folder location is an attribute that I use to pass to SystemCaller but I cant figure out how to pass this attribute value to say a FileCopy or even a FeatureReader. The output folder is a concatonated path $(FME_WORKSPACE_DIR) + _output that I made as a new attribute value (_output_folder).
In the pic below, I tried to connect the Logger to FileCopy but that doesnt seem to do anything
here is the FileCopy settings i am using.
Am I doing this correctly or any other suggestions?
Page 1 / 1
You’re on the right track, and i’ll be honest, I always forget how to setup the filecopy writer
As the name suggests, the filecopy_source_dataset attribute is the folder/file you want to copy
In the writer, the Destination File Copy Folder is where you want to copy the above file to
On the canvas, the feature type (subfolder name) is the name you want to give the folder/file
Now this is where it gets a bit confusing, specifically for folders. You say you’d like to zip it? so you’d think you’d just change the feature type to end in .zip. However if you do that, it copies it to a folder with the name .zip
To zip it up, you actually need to add the zip type to the writer. But in doing this, you’ll then copy the source folder into a zip file, so the structure would be “/folder.zip/folder”.
To fix this, you set the feature type on the canvas to ‘\’ then set the writer to the full path of the output zip file.
Example:
You want to copy C:\temp\New Folder to C:\temp\copiedfolder.zip
Filecopy_source_dataset
Destination File Copy Folder
Feature Type/Subfolder Name
Final output location
C:\Temp\New folder
C:\Temp
copiedfolder
C:\Temp\copiedfolder
C:\Temp\New folder
C:\Temp
copiedfolder.zip
C:\Temp\copiedfolder.zip (not an actual zip file)
C:\Temp\New folder
C:\Temp.zip
copiedfolder
C:\Temp.zip\copiedfolder (actual zip file)
C:\Temp\New folder
C:\Temp\copiedfolder.zip
\
C:\Temp\copiedfolder.zip
(actual zip file)
Hi @norris ,
I suppose you are attempting to archive all the resulting files saved in "$(FME_WORKSPACE_DIR)_output" folder into "$(FME_WORKSPACE_DIR)_output.zip" file. If I understand your requirement correctly, FeatureWriter could help you.
Rename the attribute "_output_folder" to "filecopy_source_dataset" with AttributeManager or AttributeRenamer.
Add FeatureWriter and set parameters as in:
Format: File Copy
Dataset: @Value(filecopy_source_dataset).zip
Subfolder Name: <a preferable subfolder name. "." or "/" if subfolder is not needed>
See also the scrennshot.
Thank you @takashi and @hkingsbury for the help and suggestions!! I ended up using a FeatureReader and FileCopy solution as I couldnt get just the FileCopy to work but the information on how the FileCopy works is so helpful.
My solution:
Now I can use Python (with Conda env) and FME ! Been fighting for the last few weeks trying to get that combo to play nicely.