Skip to content

Commit

Permalink
Simplify expression for dicts yield
Browse files Browse the repository at this point in the history
  • Loading branch information
arturponinski committed Aug 18, 2022
1 parent 3d23cea commit 662b785
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions petl/io/json.py
Expand Up @@ -234,7 +234,7 @@ def __iter__(self):
o = next(it)
except StopIteration:
break
row = tuple(o[f] if f in o else self.missing for f in self._header)
row = tuple(o.get(f, self.missing) for f in self._header)
self._filecache.seek(self._cached)
pickle.dump(row, self._filecache, protocol=-1)
self._cached = position = self._filecache.tell()
Expand Down Expand Up @@ -290,7 +290,7 @@ def iterdicts(dicts, header, sample, missing):

# generate data rows
for o in it:
yield tuple(o[f] if f in o else missing for f in header)
yield tuple(o.get(f, missing) for f in header)


def tojson(table, source=None, prefix=None, suffix=None, *args, **kwargs):
Expand Down

0 comments on commit 662b785

Please sign in to comment.