def __iter__(self):
""" Return an iterator to the data. Yield the value for self.key
from each object
"""
start = 0
while start < self.num_entries:
end = min(self.num_entries, start + self.chunk_size)
# linecache line numbering starts at 1
batch = [
json.loads(
linecache.getline(
self.source,
i + 1
).strip()
)[self.key]
for i in self.indices[start:end]
]
yield batch
start = end
###########################################################################
评论列表
文章目录