예제 #1
0
파일: io.py 프로젝트: deytao/petl
 def __iter__(self):
     result = self.dicts
     if self.header is None:
         # determine fields
         header = list()
         for o in result:
             if hasattr(o, 'keys'):
                 header.extend(k for k in o.keys() if k not in header)
     else:
         header = self.header
     yield tuple(header)
     # output data rows
     for o in result:
         row = tuple(o[f] if f in o else None for f in header)
         yield row
예제 #2
0
파일: io.py 프로젝트: deytao/petl
 def __iter__(self):
     with self.source.open_() as f:
         result = json.load(f, *self.args, **self.kwargs)
         if self.header is None:
             # determine fields
             header = list()
             for o in result:
                 if hasattr(o, 'keys'):
                     header.extend(k for k in o.keys() if k not in header)
         else:
             header = self.header
         yield tuple(header)
         # output data rows
         for o in result:
             row = tuple(o[f] if f in o else None for f in header)
             yield row