Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option my_range to method iterRecords #308

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ def records(self, fields=None):
records.append(r)
return records

def iterRecords(self, fields=None):
def iterRecords(self, fields=None, my_range=None):
"""Returns a generator of records in a dbf file.
Useful for large shapefiles or dbf files.
To only read some of the fields, specify the 'fields' arg as a
Expand All @@ -1820,7 +1820,9 @@ def iterRecords(self, fields=None):
f = self.__getFileObj(self.dbf)
f.seek(self.__dbfHdrLength)
fieldTuples, recLookup, recStruct = self.__recordFields(fields)
for i in xrange(self.numRecords):
if my_range is None:
my_range = xrange(self.numRecords)
for i in my_range:
r = self.__record(
oid=i, fieldTuples=fieldTuples, recLookup=recLookup, recStruct=recStruct
)
Expand Down
Loading