Spaces:
Sleeping
Sleeping
File size: 1,200 Bytes
fe8a467 | 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 | 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}")
|