Does anybody have a good method of doing this?
I've tried using the zipfile python library but am utterly confused on how to do it for a file geodatabase since it's not exactly a directory/file structure. My folder structure looks like so, I want to zip up the folder/geodatabase outlined in red:
I've tried this (all the indentation is correct in my script, don't know why GeoNet is changing it upon publishing the question):
import zipfile
myzipfile = zipfile.ZipFile("D:\GIS_Testing\HabitatDbase\MyZip.zip", 'w', zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk("D:\GIS_Testing\HabitatDbase"):
if root == "D:\GIS_Testing\HabitatDbase\HabitatData.gdb":
for f in files:
myzipfile.write(os.path.join(root, file))
I've also tried using shutil.make_archive and for some reason instead of zipping up my file geodatabase it zips up my python script file which is completely bewildering as I have no idea how it would even get the path to the script file...
I get a TypeError on the last line that says "object of type 'type' has no len()"