Database Reference
In-Depth Information
return 'text/plain'
def start(self, out):
'''Called before the first row is output.'''
pass
def format(self, out):
'''Called for each batch of rows to be
formatted.'''
pass
def finish(self, out):
'''Called after all rows have been written.'''
pass
class _CSV(_Formatter):
'''Format rows as CSV.'''
def format(self, rows, out):
out.write('\n'.join([
','.join([cell.get('v') for cell in
row.get('f')])
for row in rows]))
class _Datatable(_Formatter):
'''Format data for consumption by the google
visualization library.'''
def __init__(self, config):
self._columns = json.dumps(config.columns)
# Need to cast values because the Datatable will
treat strings
# as 0 rather than casting to a number.
self._converters = [
float if c['type'] == 'number' else str
for c in config.columns
]
self._add_comma = False
def _cast(self, cols):
Search WWH ::




Custom Search