I'm trying loop over many arrays and create files stored in different folders.
Is there a way to have np.savetxt creating the folders I need as well?
Thanks
savetxt just does a open(filename, 'w'). filename can include a directory as part of the path name, but you'll have to first create the directory with something like os.mkdir. In other words, use the standard Python directory and file functions.
Actually in order to make all intermediate directories if needed the os.makedirs(path, exist_ok=True) . If not needed the command will not throw an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With