I am using this line to create a new file (the file does not exist):
with open(outfilename, 'rwb') as outfile:
And it gets this error:
IOError: [Errno 2] No such file or directory: 'myoutfile.csv'
I am trying to create this file, and I thought if I used ‘w’ that would create it if it doesn’t exist. If it is permissions, how do I create a new folder and refer to its path?
The open mode passed to the
open()function accepts only a specific few combinations of letters. In your case,'rwb'is not one of those combinations, and Python is perhaps assuming that you meant'rb'. Try:This opens the file for writing. If you need to both write to and read from the same handle, use: