Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| import streamlit as st | |
| import json | |
| def load_table_config(file_path: str) -> dict: | |
| """Load the table configuration JSON.""" | |
| with open(file_path, 'r') as f: | |
| return json.load(f) | |
| def load_uploaded_files(uploaded_files): | |
| """ | |
| Load dataframes from the uploaded files (CSV/Excel). | |
| Returns a list of pandas DataFrames. | |
| """ | |
| dataframes = [] | |
| for file in uploaded_files: | |
| if file.name.endswith('.csv'): | |
| df = pd.read_csv(file) | |
| else: | |
| df = pd.read_excel(file) | |
| dataframes.append(df) | |
| return dataframes | |
| def display_table_descriptions(selected_tables, table_config): | |
| """ | |
| Given a list of selected table names and the table config, | |
| write out their descriptions in the sidebar. | |
| """ | |
| if selected_tables: | |
| st.sidebar.subheader("Table Descriptions") | |
| for table_name in selected_tables: | |
| description = table_config[table_name].get('description', "No description available.") | |
| cols = table_config[table_name].get('cols', []) | |
| st.sidebar.markdown(f"**{table_name}**: {description}") | |
| st.sidebar.markdown(f"**Available columns**: {cols}") | |