(key_name, csv_filename, yml_filename)
Given a file path to a single csv file convert it to a yaml file

        :param key_name: integration key name for root object
        :param csv_filename: path to input csv file
        :param yml_filename: path to output yml file
Given a file path to a single csv file convert it to a yaml file
Given a file path to a single csv file convert it to a yaml file
def metric_csv_to_yaml(key_name, csv_filename, yml_filename):
        """
        Given a file path to a single csv file convert it to a yaml file

        :param key_name: integration key name for root object
        :param csv_filename: path to input csv file
        :param yml_filename: path to output yml file
        """
        yaml_data = {key_name: []}
        with open(csv_filename) as csv_file:
            reader = csv.DictReader(csv_file, delimiter=",")
            yaml_data[key_name] = [
                dict(line) for line in reader
            ]
        if yaml_data[key_name]:
            # Transforming the metric description to html in order to interpret markdown in
            # integrations metrics table.
            # the char strip is to compensate for the lib adding <p> </p><br> tags
            for metric in yaml_data[key_name]:
                metric['description'] = str(
                    markdown2.markdown(metric['description']))[3:-5]
            with open(
                file=yml_filename,
                mode="w",
                encoding="utf-8",
            ) as f:
                f.write(
                    yaml.dump(
                        yaml_data, default_flow_style=False
                    )
                )
def metric_csv_to_yaml ( key_name , csv_filename , yml_filename ) : yaml_data = { key_name : [ ] } with open ( csv_filename ) as csv_file : reader = csv . DictReader ( csv_file , delimiter = "," ) yaml_data [ key_name ] = [ dict ( line ) for line in reader ] if yaml_data [ key_name ] : # Transforming the metric description to html in order to interpret markdown in # integrations metrics table. # the char strip is to compensate for the lib adding <p> </p><br> tags for metric in yaml_data [ key_name ] : metric [ 'description' ] = str ( markdown2 . markdown ( metric [ 'description' ] ) ) [ 3 : - 5 ] with open ( file = yml_filename , mode = "w" , encoding = "utf-8" , ) as f : f . write ( yaml . dump ( yaml_data , default_flow_style = False ) )