Skip to content

Commit 399622d

Browse files
authored
Merge pull request #68 from karimbahgat/speedup-fix
Reverts back to original records() method to fix issue #66
2 parents fa8df8b + a656965 commit 399622d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

shapefile.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ def __dbfHeader(self):
477477
self.__recStruct = Struct(fmt)
478478

479479
def __recordFmt(self):
480-
"""Calculates the size of a .shp geometry record."""
480+
"""Calculates the format and size of a .dbf record."""
481481
if not self.numRecords:
482482
self.__dbfHeader()
483483
fmt = ''.join(['%ds' % fieldinfo[2] for fieldinfo in self.fields])
@@ -549,11 +549,13 @@ def records(self):
549549
"""Returns all records in a dbf file."""
550550
if not self.numRecords:
551551
self.__dbfHeader()
552+
records = []
552553
f = self.__getFileObj(self.dbf)
553554
f.seek(self.__dbfHeaderLength())
554-
flat = unpack(self.__recStruct.format * self.numRecords, f.read(self.__recStruct.size * self.numRecords))
555-
rowlen = len(self.fields) - 1
556-
records = list(izip(*(iter(flat),) * rowlen))
555+
for i in range(self.numRecords):
556+
r = self.__record()
557+
if r:
558+
records.append(r)
557559
return records
558560

559561
def iterRecords(self):

0 commit comments

Comments
 (0)