File size: 2,390 Bytes
57fe85f
 
 
fbf7879
 
 
 
57fe85f
 
 
 
263b2ce
56d8047
bb3e08f
 
a9f4212
57fe85f
 
 
 
bb3e08f
263b2ce
57fe85f
 
56d8047
bb3e08f
 
a9f4212
57fe85f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c73ba84
 
 
57fe85f
 
86110dd
c73ba84
86110dd
c73ba84
86110dd
 
c73ba84
86110dd
57fe85f
 
 
 
c73ba84
 
 
 
 
 
a9f4212
c73ba84
 
57fe85f
 
 
 
c73ba84
 
57fe85f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
    invunit = 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"],
    "invunit": ["INVUNIT"],
}


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]
    available_sheets_in_list = [
        sheet for sheet in sheet_list if sheet in available_sheets
    ]
    if not missing_sheets:
        setattr(Technology, technology_attr, True)
    #     print(getattr(Technology, technology_attr))
    #     print(f"available:", available_sheets_in_list)
    #     print("All sheets exist")

    # else:
    #     print(f"Missing sheets: {missing_sheets}")
    #     print(f"available:", available_sheets_in_list)
    #     print(getattr(Technology, technology_attr))


# Check each technology's sheets
def execute_checks_sheets_exist(file_path):
    Technology.gsm = False
    Technology.wcdma = False
    Technology.lte = False
    Technology.neighbors = False
    Technology.trx = False
    Technology.mrbts = False
    Technology.invunit = False
    Technology.mal = False
    DumpType.full_dump = False
    for tech_attr, sheets in sheets_to_check.items():
        check_sheets(tech_attr, sheets, file_path)


# execute_checks_sheets_exist(
#     r"C:\Users\David\Documents\PROJECTS\2023\PROJET 2023\DUMP\DUMP\2142\DUMP 2142.xlsb"
# )