I have run into an issue while working with numpy's savetxt function. I have been trying to save data deep inside a file structure. Below is a minimal working example (for you to run it you will need to make the following directories, however).
import numpy as np
dir1 = "LongDirectoryName/"
dir2 = "VeryLongDirectoryName/"
dir3 = "EvenLongerDirectoryName/"
dir4 = "LongestOfThemAllDirectoryName/"
filename = "../" + dir1 + dir2 + dir3 + dir4 + "longfilename_with_129_charss.txt" # this works
#filename = "../" + dir1 + dir2 + dir3 + dir4 + "longfilename_with_130_charsss.txt" # this does not
print(len(filename))
myarray = np.array([1,2,3])
np.savetxt(filename, myarray)
The relative filepath is not an issue because the 129 character filename does work. It seems to me that 129 characters is the limit. When I go to try the 130 character filename, I receive the following error:
File "C:\Users\njkro\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1359, in savetxt
open(fname, 'wt').close()
FileNotFoundError: [Errno 2] No such file or directory: '../LongDirectoryName/VeryLongDirectoryName/EvenLongerDirectoryName/LongestOfThemAllDirectoryName/longfilename_with_130_charsss.txt'
Other Information
I am using Windows 10.
I am using Anaconda, and the version of numpy I am using is 1.16.2.
My questions:
- Can anyone confirm this?
- Is there an explanation for this character limit? I would understand a 128 character limit more than 129.
- Is there a workaround (for long filenames) if I can't change the file system?