(aggregation, sketch, zip_file)
Export an aggregation from a sketch and write it to a ZIP file.

    Args:
        aggregation (timesketch.models.sketch.Aggregation): an aggregation
            object.
        sketch (timesketch.models.sketch.Sketch): a sketch object.
        zip_file (ZipFile): a zip file handle that can be used to write
            content to.
Export an aggregation from a sketch and write it to a ZIP file.
Export an aggregation from a sketch and write it to a ZIP file .
def export_aggregation(aggregation, sketch, zip_file):
    """Export an aggregation from a sketch and write it to a ZIP file.

    Args:
        aggregation (timesketch.models.sketch.Aggregation): an aggregation
            object.
        sketch (timesketch.models.sketch.Sketch): a sketch object.
        zip_file (ZipFile): a zip file handle that can be used to write
            content to.
    """
    name = '{0:04d}_{1:s}'.format(aggregation.id, aggregation.name)
    parameters = json.loads(aggregation.parameters)
    result_obj, meta = utils.run_aggregator(
        sketch.id, aggregator_name=aggregation.agg_type,
        aggregator_parameters=parameters)

    zip_file.writestr(
        'aggregations/{0:s}.meta'.format(name), data=json.dumps(meta))

    html = result_obj.to_chart(
        chart_name=meta.get('chart_type'),
        chart_title=aggregation.name,
        color=meta.get('chart_color'),
        interactive=True, as_html=True)
    zip_file.writestr(
        'aggregations/{0:s}.html'.format(name), data=html)

    string_io = io.StringIO()
    data_frame = result_obj.to_pandas()
    data_frame.to_csv(string_io, index=False)
    string_io.seek(0)
    zip_file.writestr(
        'aggregations/{0:s}.csv'.format(name), data=string_io.read())
def export_aggregation ( aggregation , sketch , zip_file ) : name = '{0:04d}_{1:s}' . format ( aggregation . id , aggregation . name ) parameters = json . loads ( aggregation . parameters ) result_obj , meta = utils . run_aggregator ( sketch . id , aggregator_name = aggregation . agg_type , aggregator_parameters = parameters ) zip_file . writestr ( 'aggregations/{0:s}.meta' . format ( name ) , data = json . dumps ( meta ) ) html = result_obj . to_chart ( chart_name = meta . get ( 'chart_type' ) , chart_title = aggregation . name , color = meta . get ( 'chart_color' ) , interactive = True , as_html = True ) zip_file . writestr ( 'aggregations/{0:s}.html' . format ( name ) , data = html ) string_io = io . StringIO ( ) data_frame = result_obj . to_pandas ( ) data_frame . to_csv ( string_io , index = False ) string_io . seek ( 0 ) zip_file . writestr ( 'aggregations/{0:s}.csv' . format ( name ) , data = string_io . read ( ) )