db_query / apps /ciq_3g_generator.py
DavMelchi's picture
Add CIQ 3G Generator with WBTS/WCEL sheet generation, refactor CIQ 2G to extract shared site parsing logic with MCC/MNC parameters, implement TRX sheet builder with BCCH/TRX frequency parsing and MAIO assignment, add BTS sheet builder with template name detection and sector ID mapping, and create MAL sheet builder with mobile allocation frequency extraction from CIQ brut Excel
1e7ca72
import pandas as pd
import streamlit as st
from queries.process_ciq_3g import generate_ciq_3g_excel
st.title("CIQ 3G Generator")
ciq_file = st.file_uploader(
"Upload CIQ brut 3G (Excel)", type=["xlsx", "xls"], key="ciq3g_ciq"
)
col1, col2 = st.columns(2)
with col1:
year_suffix = st.text_input("Year suffix", value="25", key="ciq3g_year")
with col2:
bands = st.text_input(
"Bands string",
value="G9G18U9U21L8L18L26",
key="ciq3g_bands",
)
if ciq_file is None:
st.info("Upload CIQ brut 3G Excel to generate CIQ 3G (WBTS + WCEL).")
st.stop()
if st.button("Generate", type="primary"):
try:
with st.spinner("Generating CIQ 3G..."):
sheets, excel_bytes = generate_ciq_3g_excel(
ciq_file, year_suffix=year_suffix.strip(), bands=bands.strip()
)
st.session_state["ciq3g_sheets"] = sheets
st.session_state["ciq3g_excel_bytes"] = excel_bytes
st.success("CIQ 3G generated")
except Exception as e:
st.error(f"Error: {e}")
sheets = st.session_state.get("ciq3g_sheets")
excel_bytes = st.session_state.get("ciq3g_excel_bytes")
if sheets:
tab_names = list(sheets.keys())
tabs = st.tabs(tab_names)
for t, name in zip(tabs, tab_names):
with t:
df: pd.DataFrame = sheets[name]
st.dataframe(df, use_container_width=True)
if excel_bytes:
st.download_button(
label="Download CIQ 3G Excel",
data=excel_bytes,
file_name="CIQ_3G.xlsx",
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
type="primary",
)