def get_csv_data(self,
                     output_file,
                     period_start,
                     period_end,
                     entity,
                     data_type: DrillingDataType,
                     decimal_format=','):
        """
        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 written to the specified csv file.

        Parameters
        ----------
        output_file : full path to where to store csv file
        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
        decimal_format : the decimal format to use e.g. , or .
        """
        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_csv(frame,
                                 output_file,
                                 decimal_format=decimal_format)
    def get_csv_data(self,
                     output_file,
                     period_start,
                     period_end,
                     entity,
                     data_type,
                     product='',
                     decimal_format=',',
                     reportType='',
                     additionalFilter=''):
        """
        Will run a GraphQL query against the Collabor8 platform and ask for production data of the given type
        and using the specified OAuth2 token for authentication. Data is written to the specified csv file.

        Parameters
        ----------
        output_file : full path to where to store csv file
        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
        decimal_format : the decimal format to use
        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_csv(frame,
                                 output_file,
                                 decimal_format=decimal_format)
示例#3
0
 def test_lithology_to_excel(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.csv')
     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_csv(normalized_frame,result_file)
         print ("CSV result written to:"+result_file)
     except Exception as err:
         self.fail("Query drilling lithology failed with error:"+str(err)) 
示例#4
0
 def test_status_info_to_csv(self):
     result_file = os.path.join(os.path.dirname(__file__)+"/data/", 'drilling_status_info_result.csv')
     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_csv(normalized_frame,result_file)
         print ("CSV result written to:"+result_file)
     except Exception as err:
         self.fail("Query drilling status info failed with error:"+str(err)) 
 def test_production_volumes_to_csv(self):
     result_file = os.path.join(
         os.path.dirname(__file__) + "/data/",
         'production_volumes_result.csv')
     start = "2017-10-31T23:00:00.000Z"
     end = "2017-11-20T12:00:00.000Z"
     entity = "34/10-A-23"
     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_csv(normalized_frame, result_file)
         print("CSV result written to:" + result_file)
     except Exception as err:
         self.fail("Query production volumes failed with error:" + str(err))