AnsweredAssumed Answered

Unzipping shapefiles in Arc 9.3 - Python 2.5

Question asked by mdenil on Apr 20, 2012
Latest reply on Apr 23, 2012 by lpinner
The method for unzipping files in python 2.5 (Arc9.3) is a bit round-about.
In 2.6 (Arc 10) one gets both an extract() and an extractall() method, either of which which work like a charm...

HOWEVER, in 2.5 one has to read each file in the zip into a disk file.
to wit:

z = r"C:\" zf = zipfile.ZipFile(z, 'r') nameList = zf.namelist() for n in nameList:     print n     outFile = open("%s\\%s" % (r"C:", n), 'w')     outFile.write(     outFile.close()

This extracts most of the shapefile, but the .shp is damaged. ArcCatalog gives it a question mark icon, and it won't open.
The .dbf seems fine (it can be read by itself), and the .prj and .xml are also readable, but the .shp is the wrong size.
It is, in fact, larger than it would be unzipping with WinZip, and larger than zf.printdir() reports inside the zip.
(about 8,200 bytes larger)

I have to support some legacy Arc 9.3 installations for a few more months, so it would be nice to know how I can pry a shapefile out of its zip without rim-wracking it.