Skip to content

Commit c86c4f4

Browse files
Merge pull request #11 from 7mp/master
Added `Reader.iterShapeRecords` to help work with larger files
2 parents cba0c99 + 79cc409 commit c86c4f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

shapefile.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import time
1717
import array
1818
import tempfile
19+
import itertools
1920

2021
#
2122
# Constants for shape types
@@ -567,6 +568,13 @@ def shapeRecords(self):
567568
return [_ShapeRecord(shape=rec[0], record=rec[1]) \
568569
for rec in zip(self.shapes(), self.records())]
569570

571+
def iterShapeRecords(self):
572+
"""Returns a generator of combination geometry/attribute records for
573+
all records in a shapefile."""
574+
for shape, record in itertools.izip(self.iterShapes(), self.iterRecords()):
575+
yield _ShapeRecord(shape=shape, record=record)
576+
577+
570578
class Writer:
571579
"""Provides write support for ESRI Shapefiles."""
572580
def __init__(self, shapeType=None):

0 commit comments

Comments
 (0)