import pandas as pd
import logging
import json
import yaml
import os
import io
def read_yaml(path_to_yaml: str) -> dict:
    with open(path_to_yaml) as yaml_file:
        content = yaml.safe_load(yaml_file)
    logging.info(f"yaml file: {path_to_yaml} loaded successfully")
    return content

def create_directories(path_to_directories: list) -> None:
    for path in path_to_directories:
        os.makedirs(path, exist_ok=True)
        logging.info(f"created directory at: {path}")


def save_json(path: str, data: dict) -> None:
    with open(path, "w") as f:
        json.dump(data, f, indent=4)

    logging.info(f"json file saved at: {path}")


# def load_model(model):
#     with io.StringIO() as stream:
#         pd.read_excel(print_fn = lambda x: stream.write(f'{x}\n'))
#         summary_str = stream.getvalue()
#     return summary_str
import pandas as pd
import logging
import json
import yaml
import os
import io
def read_yaml(path_to_yaml: str) -> dict:
    with open(path_to_yaml) as yaml_file:
        content = yaml.safe_load(yaml_file)
    logging.info(f"yaml file: {path_to_yaml} loaded successfully")
    return content

def create_directories(path_to_directories: list) -> None:
    for path in path_to_directories:
        os.makedirs(path, exist_ok=True)
        logging.info(f"created directory at: {path}")


def save_json(path: str, data: dict) -> None:
    with open(path, "w") as f:
        json.dump(data, f, indent=4)

    logging.info(f"json file saved at: {path}")


# def load_model(model):
#     with io.StringIO() as stream:
#         pd.read_excel(print_fn = lambda x: stream.write(f'{x}\n'))
#         summary_str = stream.getvalue()
#     return summary_str
# def load_model(model): #     with io.StringIO() as stream: #         pd.read_excel(print_fn = lambda x: stream.write(f'{x}\n')) #         summary_str = stream.getvalue() #     return summary_str