import pandas as pd import streamlit as st st.title("Dump Core Parsing") # Initialize a list to hold the extracted data data_global_cell_id = [] data_la_cell_name = [] data_wcdma_service_area_number = [] data_wcdma_service_area_name = [] # Create a Streamlit file uploader uploaded_files = st.file_uploader( "Upload Core Creation dump files", type=["txt"], accept_multiple_files=True ) # Process each uploaded file if uploaded_files: all_data_global_cell_id = [] all_data_la_cell_name = [] all_data_wcdma_service_area_number = [] all_data_wcdma_service_area_name = [] for file in uploaded_files: # Read the content of the file content = file.read().decode("utf-8").splitlines() data_global_cell_id = [] data_la_cell_name = [] data_wcdma_service_area_number = [] data_wcdma_service_area_name = [] # Loop through each line in the file for line in content: if "Global cell ID" in line: data_global_cell_id.append([line.split("=")[1].strip()]) elif "LA cell name" in line: data_la_cell_name.append([line.split("=")[1].strip()]) elif "3G service area number" in line: data_wcdma_service_area_number.append([line.split("=")[1].strip()]) elif "3G service area name" in line: data_wcdma_service_area_name.append([line.split("=")[1].strip()]) # Append the extracted data for the current file to the overall lists all_data_global_cell_id.extend(data_global_cell_id) all_data_la_cell_name.extend(data_la_cell_name) all_data_wcdma_service_area_number.extend(data_wcdma_service_area_number) all_data_wcdma_service_area_name.extend(data_wcdma_service_area_name) # Create a DataFrame from the extracted data df_global_cell_id = pd.DataFrame( all_data_global_cell_id, columns=["Global cell ID"] ) df_la_cell_name = pd.DataFrame(all_data_la_cell_name, columns=["LA cell name"]) df_wcdma_service_area_number = pd.DataFrame( all_data_wcdma_service_area_number, columns=["3G service area number"] ) df_wcdma_service_area_name = pd.DataFrame( all_data_wcdma_service_area_name, columns=["3G service area name"] ) # add index column df_global_cell_id and df_la_cell_name and dfa_wcdma_service_area_numbera and df_wcdma_service_area_name df_global_cell_id.insert(0, "index", range(0, len(df_global_cell_id))) df_la_cell_name.insert(0, "index", range(0, len(df_la_cell_name))) df_wcdma_service_area_number.insert( 0, "index", range(0, len(df_wcdma_service_area_number)) ) df_wcdma_service_area_name.insert( 0, "index", range(0, len(df_wcdma_service_area_name)) ) # Merge global_cell_id and la_cell_name on index df_la_cell_name = df_la_cell_name.merge(df_global_cell_id, on="index") # merge wcdma_service_area_number and wcdma_service_area_name on index df_wcdma_service_area_name = df_wcdma_service_area_name.merge( df_wcdma_service_area_number, on="index" ) df_la_cell_name["LAC_ID"] = df_la_cell_name["Global cell ID"].str[5:] df_wcdma_service_area_name["LAC_ID"] = df_wcdma_service_area_name[ "3G service area number" ].str[5:] df_la_cell_name["LAC"] = df_la_cell_name["LAC_ID"].str[:4] df_la_cell_name["Cell ID"] = df_la_cell_name["LAC_ID"].str[4:] df_wcdma_service_area_name["LAC"] = df_wcdma_service_area_name["LAC_ID"].str[:4] df_wcdma_service_area_name["Cell ID"] = df_wcdma_service_area_name["LAC_ID"].str[4:] # convert LAC to from HEXadecimal to DECimal df_la_cell_name["LAC_DECIMAL"] = df_la_cell_name["LAC"].apply(lambda x: int(x, 16)) df_la_cell_name["Cell_ID_DECIMAL"] = df_la_cell_name["Cell ID"].apply( lambda x: int(x, 16) ) df_wcdma_service_area_name["LAC_DECIMAL"] = df_wcdma_service_area_name["LAC"].apply( lambda x: int(x, 16) ) df_wcdma_service_area_name["Cell_ID_DECIMAL"] = df_wcdma_service_area_name[ "Cell ID" ].apply(lambda x: int(x, 16)) df_la_cell_name = df_la_cell_name.reset_index(drop=True) # Display the DataFrame st.subheader("2G CORE DUMP DATA") st.write(df_la_cell_name) st.subheader("3G CORE DUMP DATA") st.write(df_wcdma_service_area_name)