File size: 523 Bytes
022acf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os

import pandas as pd
import yaml

from newsclassifier.config.config import Cfg, logger


def write_yaml(data: pd.DataFrame, filepath: str):
    logger.info("Writing yaml file.")
    os.makedirs(os.path.dirname(filepath), exist_ok=True)
    with open(filepath, "w") as file:
        yaml.dump(data, file, default_flow_style=False)


def read_yaml(file_path: str):
    logger.info("Reading yamlfile")
    with open(file_path, "r") as file:
        params = yaml.load(file, Loader=yaml.FullLoader)
    return params