File size: 1,776 Bytes
b9e6156 1e7ca72 b9e6156 1e7ca72 b9e6156 |
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 |
import pandas as pd
import streamlit as st
from queries.process_ciq_2g import generate_ciq_2g_excel
st.title("CIQ 2G Generator")
col1, col2 = st.columns(2)
with col1:
dump_file = st.file_uploader("Upload dump file", type=["xlsb"], key="ciq2g_dump")
with col2:
ciq_file = st.file_uploader(
"Upload CIQ brut 2G (Excel)", type=["xlsx", "xls"], key="ciq2g_ciq"
)
col3, col4 = st.columns(2)
with col3:
mcc = st.number_input("MCC", value=610, step=1, min_value=0, key="ciq2g_mcc")
with col4:
mnc = st.number_input("MNC", value=2, step=1, min_value=0, key="ciq2g_mnc")
if dump_file is None or ciq_file is None:
st.info("Upload dump xlsb + CIQ brut Excel to generate CIQ 2G.")
st.stop()
if st.button("Generate", type="primary"):
try:
with st.spinner("Generating CIQ 2G... (dump is heavy)"):
sheets, excel_bytes = generate_ciq_2g_excel(
dump_file, ciq_file, mcc=int(mcc), mnc=int(mnc)
)
st.session_state["ciq2g_sheets"] = sheets
st.session_state["ciq2g_excel_bytes"] = excel_bytes
st.success("CIQ 2G generated")
except Exception as e:
st.error(f"Error: {e}")
sheets = st.session_state.get("ciq2g_sheets")
excel_bytes = st.session_state.get("ciq2g_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 2G Excel",
data=excel_bytes,
file_name="CIQ_2G.xlsx",
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
type="primary",
)
|