how can I create an empty txt-file with the python startup script?
That file has to be into the same directory, where the data in the workflow will writen to. So I will need the "DestDataset_SHAPE" as the directory and "LTYP.mif" as the filename.
Thanks very much for your support.
Best answer by takashi
An example.
# Startup Python Script Example import fme, os
# Get the destination folder path. dir = fme.macroValues['DestDataset_SHAPE']
# Create the folder if it doesn't exist. if not os.path.exists(dir): os.makedirs(dir)
# Create an empty file. # Open a file with writing mode, and then just close it. with open(os.path.join(dir, 'LTYP.mif'), 'w'): pass
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.
Thanks for this answers. I tried both, but I get allways this error message:
|ERROR |Python Exception <IndentationError>: unexpected indent (<string>, line 2)
|ERROR |Error executing string ` # Startup Python Script Example
import fme, os
# Get the destination folder path.
dir = fme.macroValues['DestDataset_SHAPE']
# Create the folder if it doesn't exist.
if not os.path.exists(dir):
os.makedirs(dir)
# Create an empty file.
# Open a file with writing mode, and then just close it.
with open(os.path.join(dir, 'LTYP.mif'), 'w'):
pass'
|ERROR |FME_BEGIN_PYTHON failed to execute provided script
What could be the problem here?
Identations are meaningful in Python, you will have to make sure you match the exact same indents as used by Takashi. Otherwise you will get this error.