Web Analytics Made Easy -

Node Dangles


Ever since the ever-popular post, Zipping a shapefile using python, came out, people have been asking (one person, yesterday) for a sample of how to zip a file geodatabase using python. The key trick, as shown in line 17, is appending the basename of the file geodatabase (‘nfg.gdb/’ in my example) in front of each file as you write it to the zipfile. UPDATE: WordPress messes with the spacing when I post code, making it difficult to post code that can just be copied & pasted and have work.
UPDATE: After receiving a request to modify the code to ignore .lock files, I have an updated to this post. One of the tasks I’ve been automating is publishing a weekly data update to a website. The update consists of shapefile. The trouble with shapefiles is they consist of 3 or more files with the same basename but different extensions in the same directory. Not an overly complicated situation but a common one that ArcGIS does not have a solution out-of-the-box.