Hey,
I came across a strange error just moments ago, either it’s just me and my colleagues collectivly missing the point (by miles!), or there is a fundamental error in writing files with python in dynamo. I know what I think is the likelier scenario…
Anyway,
I just want to do a simple file = open(filepath, mode)
to log some data to a .txt document on my drive every time the script is run.
these are the lines of code thats supposed to do the work, get_data()
beeing the function that collects the data i want to log and formats it into a string.
log_dir = "C:\\testlog"
filename = "testlog.txt"
filepath = log_dir + '\\' + filename
filepath = str(filepath)
file = open(filepath, "a")
file.write('\n')
file.write(get_data())
file.close()
When running i get:
line 52 beeing: file = open(filepath, "a")
.
I find no information that ironpython should be any different than python 2.7 or 3.6 in regards to open() or any information about this particular issue in Dynamo, in fact I’ve seen examples doing the exact same thing as above posted that seems to work for other. Also the script works without any errors when I run it in PyCharm with python 2.7.13 interpreter.
Very greatful for any tips as to what’s wrong here!!
Best
/Jakob