When using the play button you mentioned the script is only run locally in the IDE. So your path is not known by the script instance when run on the ctrlX CORE.
You can also start the script in an interpreter instance by using the debugger (e.g. for testing before using the PLC for starting). See my working example for reading and writing:
FileName1 = "/var/snap/rexroth-solutions/common/solutions/activeConfiguration/tiger/projects/CsvReadWrite/csvdata1.csv"
FileName2 = "/var/snap/rexroth-solutions/common/solutions/activeConfiguration/tiger/projects/CsvReadWrite/csvdata2.csv"
file1 = open(FileName1,"r")
file2 = open(FileName2,"w")
for x in file1:
data = x.split(",")
for y in data:
print(y)
file2.write(y + ",")
file1.close()
file2.close()
IDE textual editor script launch setting
... View more