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

Reverts back to original records() method to fix issue #66 #68

Merged
merged 3 commits into from
Sep 22, 2016
Merged
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
10 changes: 6 additions & 4 deletions shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def __dbfHeader(self):
self.__recStruct = Struct(fmt)

def __recordFmt(self):
"""Calculates the size of a .shp geometry record."""
"""Calculates the format and size of a .dbf record."""
if not self.numRecords:
self.__dbfHeader()
fmt = ''.join(['%ds' % fieldinfo[2] for fieldinfo in self.fields])
Expand Down Expand Up @@ -549,11 +549,13 @@ def records(self):
"""Returns all records in a dbf file."""
if not self.numRecords:
self.__dbfHeader()
records = []
f = self.__getFileObj(self.dbf)
f.seek(self.__dbfHeaderLength())
flat = unpack(self.__recStruct.format * self.numRecords, f.read(self.__recStruct.size * self.numRecords))
rowlen = len(self.fields) - 1
records = list(izip(*(iter(flat),) * rowlen))
for i in range(self.numRecords):
r = self.__record()
if r:
records.append(r)
return records

def iterRecords(self):
Expand Down