Using pyshp to read a file-like object from a zipped archive

I have been using StringIO for reading zipped shapefiles with pyshp and it worked fine.

#shapefile.__version__ '1.2.3'


from __future__ import print_function
import zipfile
import StringIO
import shapefile

zipshape = zipfile.ZipFile(open(r'C:\GIS\Temp\RoadsShapefileFolder.zip', 'rb'))
print(zipshape.namelist())
dbfname, _, shpname, _, shxname = zipshape.namelist()
r = shapefile.Reader(shp=StringIO.StringIO(zipshape.read(shpname)),
                     shx=StringIO.StringIO(zipshape.read(shxname)),
                     dbf=StringIO.StringIO(zipshape.read(dbfname)))

print(r.bbox)
print(r.numRecords)

Output:

['Roads.dbf', 'Roads.prj', 'Roads.shp', 'Roads.shp.xml', 'Roads.shx']
[279629.7664999999, 6137207.9419, 916929.7043000003, 7595571.024099998]
365

Make sure you access the right files within the zip as they are sorted alphabetically.