db_query / utils /check_sheet_exist.py
DavMelchi's picture
Add Analitic dashboards for each database (Count of NE)
fbf7879
raw
history blame
1.86 kB
import pandas as pd
class DumpType:
full_dump = False
class Technology:
gsm = False
wcdma = False
lte = False
neighbors = False
trx = False
mrbts = False
mal = False
# Dictionary of sheet groups to check
sheets_to_check = {
"gsm": ["BTS", "BCF", "TRX", "MAL"],
"neighbors": ["ADCE", "ADJS", "ADJI", "ADJG", "ADJW", "BTS", "WCEL"],
"wcdma": ["WCEL", "WBTS", "WNCEL"],
"lte": ["LNBTS", "LNCEL", "LNCEL_FDD", "LNCEL_TDD"],
"trx": ["TRX", "BTS"],
"mrbts": ["MRBTS"],
"mal": ["MAL", "BTS"],
}
def load(file_path):
# Load the Excel file
xlsb_file = pd.ExcelFile(file_path, engine="calamine")
# Get all sheet names in the file
available_sheets = xlsb_file.sheet_names
return available_sheets
def check_sheets(technology_attr, sheet_list, file_path):
"""
Check if all sheets in the given sheet_list exist in the Excel file.
Parameters
----------
technology_attr : str
The attribute of the Technology class to set.
sheet_list : list[str]
The list of sheet names to check.
Returns
-------
None
"""
available_sheets = load(file_path)
missing_sheets = [sheet for sheet in sheet_list if sheet not in available_sheets]
if not missing_sheets:
setattr(Technology, technology_attr, True)
# print(getattr(Technology, technology_attr))
# print("All sheets exist")
# else:
# print(f"Missing sheets: {missing_sheets}")
# print(getattr(Technology, technology_attr))
# Check each technology's sheets
def execute_checks_sheets_exist(file_path):
for tech_attr, sheets in sheets_to_check.items():
check_sheets(tech_attr, sheets, file_path)
# execute_checks(
# r"C:\Users\HP\Desktop\LTE\PROJET 2023\DUMP\2024\AOUT\20240822_7837_22082024_Dump.xml.gz.xlsb"
# )