import pandas as pd import streamlit as st from queries.process_ciq_4g import generate_ciq_4g_excel st.title("CIQ 4G Generator") ciq_file = st.file_uploader( "Upload CIQ brut 4G (Excel)", type=["xlsx", "xls"], key="ciq4g_ciq" ) col1, col2 = st.columns(2) with col1: year_suffix = st.text_input("Year suffix", value="25", key="ciq4g_year") with col2: bands = st.text_input( "Bands string", value="G9G18U9U21L8L18L26", key="ciq4g_bands", ) col3, col4 = st.columns(2) with col3: mcc = st.number_input("MCC", value=610, step=1, min_value=0, key="ciq4g_mcc") with col4: mnc = st.number_input("MNC", value=2, step=1, min_value=0, key="ciq4g_mnc") if ciq_file is None: st.info("Upload CIQ brut 4G Excel to generate CIQ 4G export.") st.stop() if st.button("Generate", type="primary"): try: with st.spinner("Generating CIQ 4G..."): sheets, excel_bytes = generate_ciq_4g_excel( ciq_file, year_suffix=year_suffix.strip(), bands=bands.strip(), mcc=int(mcc), mnc=int(mnc), ) st.session_state["ciq4g_sheets"] = sheets st.session_state["ciq4g_excel_bytes"] = excel_bytes st.success("CIQ 4G generated") except Exception as e: st.error(f"Error: {e}") sheets = st.session_state.get("ciq4g_sheets") excel_bytes = st.session_state.get("ciq4g_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 4G Excel", data=excel_bytes, file_name="CIQ_4G.xlsx", mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", type="primary", )