|
import pandas as pd |
|
|
|
from utils.convert_to_excel import convert_dfs |
|
from utils.extract_code import extract_code_from_mrbts |
|
from utils.utils_vars import UtilsVars |
|
|
|
|
|
def process_mrbts_data(file_path: str) -> pd.DataFrame: |
|
""" |
|
Process data from the specified file path. |
|
|
|
Args: |
|
file_path (str): The path to the file. |
|
""" |
|
dfs = pd.read_excel( |
|
file_path, |
|
sheet_name=["MRBTS"], |
|
engine="calamine", |
|
skiprows=[0], |
|
) |
|
|
|
df_mrbts = dfs["MRBTS"] |
|
df_mrbts.columns = df_mrbts.columns.str.replace(r"[ ]", "", regex=True) |
|
|
|
|
|
df_mrbts = df_mrbts[df_mrbts["MRBTS"].apply(lambda x: str(x).isnumeric())].copy() |
|
|
|
|
|
df_mrbts.loc[:, "code"] = df_mrbts["MRBTS"].apply(extract_code_from_mrbts) |
|
df_mrbts = df_mrbts[["MRBTS", "code", "name", "btsName"]] |
|
|
|
UtilsVars.all_db_dfs.append(df_mrbts) |
|
UtilsVars.all_db_dfs_names.append("MRBTS") |
|
return df_mrbts |
|
|
|
|
|
def process_mrbts_data_to_excel(file_path: str) -> None: |
|
""" |
|
Process data from the specified file path and save it to a excel file. |
|
|
|
Args: |
|
file_path (str): The path to the file. |
|
""" |
|
mrbts_df = process_mrbts_data(file_path) |
|
UtilsVars.final_mrbts_database = convert_dfs([mrbts_df], ["MRBTS"]) |
|
|