0

I want to save the calculation results in a file (in a different folder than the script, but on the same level). The filename should contain parts of sys.argv[1]. Should work under Linux/Windows.

When I replace the outpufilename with a string it works and the outputfilename works if I dont use os.path.join. The cause must be the combination.

inputfilename = str(sys.argv[1])
outputfilename = inputfilename.split(".")[0] + "__calculated.csv"
basedir = '../results/'
fileDir = os.path.dirname(os.path.realpath('__file__'))
outputfile = os.path.join(fileDir, basedir + outputfilename)
  • 2
    Don't do your own concatenation. `os.path.join(fileDir, basedir, outputfilename)` – Barmar Jan 21 '19 at 09:56
  • What error messages do you get when using `os.path.join`? What's the expected output? Provide some extra information? – Eypros Jan 21 '19 at 09:56

0 Answers0