def csv_fields(series):
 rv = []
 fields = set()
 for row in series:
  fields.update(row['data'])
  rv.append(row['data'])
  row['data'].update(count=row['count'], date=row['date'])
 return (rv, fields)

def csv_fields ( series ) : rv = [ ] fields = set ( ) for row in series : fields . update ( row [ 'data' ] ) rv . append ( row [ 'data' ] ) row [ 'data' ] . update ( count = row [ 'count' ] , date = row [ 'date' ] ) return ( rv , fields )
figure out all the keys in the data dict for csv columns .