2024-05-07 18:13:51 +05:30
|
|
|
import yaml
|
2024-08-21 19:26:08 +05:30
|
|
|
import pandas as pd
|
|
|
|
|
import os
|
2024-05-07 18:13:51 +05:30
|
|
|
|
2024-08-21 19:26:08 +05:30
|
|
|
from utils.CustomException import NoYamlFile
|
2024-05-07 18:13:51 +05:30
|
|
|
|
2024-08-21 19:26:08 +05:30
|
|
|
|
|
|
|
|
def read_yaml(file_path, file_name):
|
|
|
|
|
try:
|
2024-09-30 12:21:29 +01:00
|
|
|
with open(file_path + file_name, "r") as file:
|
2024-08-21 19:26:08 +05:30
|
|
|
return yaml.safe_load(file)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
raise NoYamlFile(file_path, file_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_excel(file_path, sheet_name, col_name):
|
|
|
|
|
df = pd.read_excel(file_path, usecols=col_name, sheet_name=sheet_name)
|
|
|
|
|
if len(col_name) == 1:
|
|
|
|
|
data = [val[0] for val in df.values]
|
|
|
|
|
else:
|
|
|
|
|
data = [tuple(row) for row in df.values]
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def read_files(folder_path):
|
|
|
|
|
file_paths = []
|
|
|
|
|
for root, dirs, files in os.walk(folder_path):
|
|
|
|
|
for file in files:
|
|
|
|
|
file_paths.append(os.path.join(root, file))
|
|
|
|
|
return file_paths
|