def get_excel_data(self,
                       output_file,
                       period_start,
                       period_end,
                       entity,
                       data_type,
                       product='',
                       reportType='',
                       additionalFilter=''):
        """
        Will run a GraphQL query against the Collabor8 platform and ask for productiong data of 
        the given type and using the specified OAuth2 token for authentication. Data is as a Excel file using the specified output_file path

        Parameters
        ----------

        output_file : full path to excel file to write results to
        period_start : start of period to query for
        period_end : end of period to query for
        entity : name of asset/entity to query for
        data_type : the type of production data to query for
        reportType: the type of report to query for, default all, e.g. use MPRML-GOV, DPR and so on
        additionalFilter: use additional filtering options to add to the query e.g. data_periods:["day"] to just include reporting period day and exclude e.g. month to date on a daily report
        """
        json = self.get_json_data(period_start, period_end, entity, data_type,
                                  product, reportType, additionalFilter)
        #convert it to a pandas frame
        frame = self.__convert_data_to_frame(json)
        frame_utils.frame_to_excel(frame, output_file)
Exemplo n.º 2
0
 def test_lithology_to_csv(self):
     entity="2/4-X-4 A"
     query=queries.get_drilling_lithology_description(entity)
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'drilling_lithology_result.xlsx')
     try:
         query_obj=graph.Graph(self.token)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=drilling_frames.lithology_info_to_frame(result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame,result_file)
         print ("Excel result written to:"+result_file)
     except Exception as err:
         self.fail("Query drilling lithology failed with error:"+str(err)) 
Exemplo n.º 3
0
 def test_status_info_to_excel(self):
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'drilling_status_info_result.xlsx')
     start="2020-01-21T23:00:00.000Z"
     end="2020-03-26T12:00:00.000Z"
     entity="34/4-M-4 H"
     query=queries.get_drilling_status_info_query(start,end,entity)
     try:
         query_obj=graph.Graph(self.token)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=drilling_frames.status_info_to_frame(result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame,result_file)
         print ("Excel result written to:"+result_file)
     except Exception as err:
         self.fail("Query drilling status info failed with error:"+str(err))
Exemplo n.º 4
0
 def test_production_volumes_to_excel(self):
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'production_volumes_result_from_config.xlsx')
     start="2021-03-18"
     end="2021-03-20"
     entity="ALVE"
     volume_type='"Production","Injection","Consumption","Comments"'
     query=queries.get_production_volumes(start,end,entity,volume_type)
     
     try: 
         query_obj=graph.Graph(self.token,self.subscriptionKey,self.graphUrl)
         result=query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame=production_frames.production_volumes_to_frame(result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame,result_file)
         print ("Excel result written to:"+result_file)
     except Exception as err:
         self.fail("Query production volumes failed with error:"+str(err))       
    def get_excel_data(self, output_file, period_start, period_end, entity,
                       data_type: DrillingDataType):
        """
        Will run a GraphQL query against the Collabor8 platform and ask for drilling data of the given type
        and using the specified OAuth2 token for authentication. Data is as a Excel file using the specified output_file path

        Parameters
        ----------

        output_file : full path to excel file to write results to
        period_start : start of period to query for
        period_end : end of period to query for
        entity : name of wellbore to query for
        data_type : the type of drilling data to query for
        """
        json = self.get_json_data(period_start, period_end, entity, data_type)
        #convert it to a pandas frame
        frame = self.__convert_data_to_frame(json, data_type)
        frame_utils.frame_to_excel(frame, output_file)
 def test_production_volumes_to_excel(self):
     result_file = os.path.join(
         os.path.dirname(__file__) + "/data/",
         'production_volumes_result.xlsx')
     start = "2008-01-01"
     end = "2009-12-31"
     entity = "VOLVE"
     volume_type = '"Production"'
     query = queries.get_production_volumes(start, end, entity, volume_type)
     try:
         query_obj = graph.Graph(self.token)
         result = query_obj.query(query)
         #have the dict send it to a panda frame creation
         normalized_frame = production_frames.production_volumes_to_frame(
             result)
         #write the data to a csv file
         frame_utils.frame_to_excel(normalized_frame, result_file)
         print("Excel result written to:" + result_file)
     except Exception as err:
         self.fail("Query production volumes failed with error:" + str(err))