I've been writing some code that takes a series of Excel files as an input, and then saves a dataframe to an excel as an output. Both the input and output folders sit on a network drive, where
InputFolder = r"\\networklocation\\folder1\\folder2\\input\\"
OutputFolder = r"\\networklocation\\folder1\\folder2\\output\\"
The code is able to read the input files correctly with pd.read_excel(InputFolder +"\\filename")
, but when saving the output with df.to_excel(OutputFolder +"\\filename")
an error is thrown of "OSError: Cannot save file into a non-existent directory", where the output folder does exist.
Strangely as well this error does not exist on all devices, when running on other PCs with the exact same access, some are able to save to the output folder with no issue.
I've tried changing the folder location string to use raw string literals, but this had no effect. I've also tried changing the output code to save the excel to the InputFolder, but it still threw the non-existent directory error, even though it had just read a file from the same location.
r"\\networklocation\folder1\folder2\input"
(which can't end with a backslash) or"\\\\networklocation\\folder1\\folder2\\input\\"
but you have too many double slashes, or too few in the beginning if you take out ther
sigil.