I tried gp.workspace = path and I get a "object is not iterable" error. Below is my attempt at 9.3.1 code and below that is the error. I am sure someone will see something obvious that I am missing. Edit: Here the indents are missing - the indents don't show up when I pasted the code here but you get the idea.
#Begin code
import sys, string, arcgisscripting, os
from os import path as p
import zipfile
# Create the Geoprocessor object
gp = arcgisscripting.create()
# arcpy.overwriteOutput = True
gp.overwriteoutput=1
def ZipShapes(path, out_path):
gp.workspace = path
shapes = gp.ListFeatureClasses()
# iterate through list of shapefiles
for shape in shapes:
name = p.splitext(shape)[0]
print name
zip_path = p.join(out_path, name + '.zip')
zip = zipfile.ZipFile(zip_path, 'w',
compression=zipfile.ZIP_DEFLATED)
zip.write(p.join(path,shape), shape)
for f in gp.ListFiles('%s*' %name):
if not f.endswith('.shp'):
zip.write(p.join(path,f), f)
print 'All files written to %s' %zip_path
zip.close()
if __name__ == '__main__':
path = r'T:\\cotiss\\CobleJ\\shape2zip\\address'
outpath = r'T:\\cotiss\\CobleJ\\shape2zip\\Shape_outputs'
ZipShapes(path, outpath)
#End of code
HERE is the ERROR:
Traceback (most recent call last):
File "T:\cotiss\CobleJ\shape2zip\Shape2Zip_931.py", line 34, in <module>
ZipShapes(path, outpath)
File "T:\cotiss\CobleJ\shape2zip\Shape2Zip_931.py", line 16, in ZipShapes
for shape in shapes:
TypeError: 'geoprocessing list object' object is not iterable