Skip to content

Commit

Permalink
Dicts generator support - remove buffering arg, add flush
Browse files Browse the repository at this point in the history
  • Loading branch information
arturponinski committed Jul 12, 2022
1 parent 56de124 commit 6359c1a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion petl/io/json.py
Expand Up @@ -227,11 +227,12 @@ def __iter__(self):
yield self._header

if not self._filecache:
self._filecache = NamedTemporaryFile(delete=False, mode='wb', buffering=0)
self._filecache = NamedTemporaryFile(delete=False, mode='wb')
it = iter(self.dicts)
for o in it:
row = tuple(o[f] if f in o else self.missing for f in self._header)
pickle.dump(row, self._filecache, protocol=-1)
self._filecache.flush()
self._filecache.close()

for row in iterchunk(self._filecache.name):
Expand Down

0 comments on commit 6359c1a

Please sign in to comment.