A python script downloads 2 tables from a database, does some calculations and creates a new one, and uploads it. There are intermediate files involved and to store all the files I create a folder called “temp” in the current working directory. Before the program exits it deletes temp. This doesn’t work very well because
- If there already is a folder named temp it will be deleted
- If the program crashes before the last step of deleting temp, the next time the program runs it crashes because files with the same name exist from the previous execution.
I imagine this is a relatively common scenario. How is it normally handled?