-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Create directories when missing in to_* methods #42255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
So do we want default behaviour to be that directories are always created or an extra argument like I can add that to the documentation. Then that would be in all |
Exposing an argument to control this might be helpful and shouldn't be too much work (and would allow us to reinstate the two tests I removed). I'll defer to the maintainers as to whether this should be on or off by default, but I agree that changing these to create missing directories by default is much more intuitive for novice users. |
Then I'll also wait with the documentation until this is resolved :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I would start with a note in the docs about this
would also accept a better error message for cases like this (not sure how hard this is to detect that if you create the parent folders). (separate PR)
I don't think automatic creation of directories is a great idea to do so automatically, so after the 2 above could consider via a keyword (yes some work for this). but please propose before you do the PR.
This pull request is stale because it has been open for thirty days with no activity. Please update or respond to this comment if you're still interested in working on this. |
Thanks for the PR, but as mentioned, the team isn't keen on supporting an API that creates directories and instead would prefer a documentation approach like in https://github.com/pandas-dev/pandas/pull/42250/files. Closing. |
This is the most fundamental approach to creating new folders when a user specifies a path that is missing in file creation methods like
to_csv
,to_excel
,to_feather
etc. We can do this in io/common.py:get_handle()
conditionally when the file buffer provided is in a writable mode.to_*
methods (@joeperdefloep)