(self, sketch, zip_file)
Export all events that have been tagged and store in a ZIP file.
Export all events that have been tagged and store in a ZIP file.
Export all events that have been tagged and store in a ZIP file .
def _export_tagged_events(self, sketch, zip_file):
        """Export all events that have been tagged and store in a ZIP file."""
        result = self.datastore.search(
            sketch_id=sketch.id,
            query_string='_exists_:tag',
            query_filter=self.DEFAULT_QUERY_FILTER,
            query_dsl='',
            indices=self.sketch_indices)

        fh = export.query_results_to_filehandle(result, sketch)
        zip_file.writestr(
            'events/tagged_events.csv', data=fh.read())

        parameters = {
            'limit': 100,
            'field': 'tag',
        }
        result_obj, meta = utils.run_aggregator(
            sketch.id, aggregator_name='field_bucket',
            aggregator_parameters=parameters)

        zip_file.writestr(
            'events/tagged_event_stats.meta', data=json.dumps(meta))

        html = result_obj.to_chart(
            chart_name='hbarchart',
            chart_title='Top 100 identified tags',
            interactive=True, as_html=True)
        zip_file.writestr(
            'events/tagged_event_stats.html', 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(
            'events/tagged_event_stats.csv', data=string_io.read())
def _export_tagged_events ( self , sketch , zip_file ) : result = self . datastore . search ( sketch_id = sketch . id , query_string = '_exists_:tag' , query_filter = self . DEFAULT_QUERY_FILTER , query_dsl = '' , indices = self . sketch_indices ) fh = export . query_results_to_filehandle ( result , sketch ) zip_file . writestr ( 'events/tagged_events.csv' , data = fh . read ( ) ) parameters = { 'limit' : 100 , 'field' : 'tag' , } result_obj , meta = utils . run_aggregator ( sketch . id , aggregator_name = 'field_bucket' , aggregator_parameters = parameters ) zip_file . writestr ( 'events/tagged_event_stats.meta' , data = json . dumps ( meta ) ) html = result_obj . to_chart ( chart_name = 'hbarchart' , chart_title = 'Top 100 identified tags' , interactive = True , as_html = True ) zip_file . writestr ( 'events/tagged_event_stats.html' , 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 ( 'events/tagged_event_stats.csv' , data = string_io . read ( ) )