Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with NamedTemporaryFile(suffix='.shp').name as tmp_shp:
- df.to_file(tmp_shp)
- with NamedTemporaryFile(suffix='.shp') as tmp_shp:
- df.to_file(tmp_shp.name) # Access .name here, assuming you need a str
- tmp_shp = None
- try:
- with NamedTemporaryFile(suffix='.shp', delete=False) as tmp_shp:
- df.to_file(tmp_shp.name) # Access .name here, assuming you need a str
- ... do any other stuff with the file ...
- finally:
- if tmp_shp is not None:
- os.remove(tmp_shp.name)
- with NamedTemporaryFile(suffix='.shp') as tmp_shp:
- df.to_file(tmp_shp)
- with NamedTemporaryFile(suffix='.shp') as tmp_file:
- df.to_file(tmp_file) # As temp_file is a file object, I think to_file should work?
Add Comment
Please, Sign In to add comment