Spaces:
Sleeping
Sleeping
Commit ·
c4478d6
1
Parent(s): ee32f69
inital commit
Browse files- .python-version +1 -0
- main.py +45 -0
- pyproject.toml +9 -0
- uv.lock +0 -0
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.10
|
main.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import io
|
| 4 |
+
|
| 5 |
+
@st.cache_data(show_spinner=False)
|
| 6 |
+
def get_sheet_names(file) -> list[str]:
|
| 7 |
+
"""Return the sheet names of an Excel file."""
|
| 8 |
+
excel_file = pd.ExcelFile(file)
|
| 9 |
+
return excel_file.sheet_names
|
| 10 |
+
|
| 11 |
+
@st.cache_data(show_spinner=False)
|
| 12 |
+
def load_df(file, sheet_name):
|
| 13 |
+
"""Read a sheet from an Excel file into a DataFrame and cache the result."""
|
| 14 |
+
return pd.read_excel(file, sheet_name=sheet_name)
|
| 15 |
+
|
| 16 |
+
buffer = io.BytesIO()
|
| 17 |
+
|
| 18 |
+
def main():
|
| 19 |
+
# Create columns
|
| 20 |
+
main_col1, main_col2 = st.columns([3, 7])
|
| 21 |
+
|
| 22 |
+
# File uploader
|
| 23 |
+
with main_col1:
|
| 24 |
+
uploaded_file = st.file_uploader("Choose an Excel file", type=['xlsx', 'xls'])
|
| 25 |
+
if uploaded_file is not None:
|
| 26 |
+
# ✅ Only caching serializable sheet names
|
| 27 |
+
sheet_names = get_sheet_names(uploaded_file)
|
| 28 |
+
selected_sheet = st.selectbox("Select a sheet", options=sheet_names, index=0)
|
| 29 |
+
|
| 30 |
+
# ✅ Cache the DataFrame (serializable)
|
| 31 |
+
df = load_df(uploaded_file, selected_sheet)
|
| 32 |
+
|
| 33 |
+
st.write(df)
|
| 34 |
+
|
| 35 |
+
# Display the uploaded file's contents in the second column
|
| 36 |
+
with main_col2:
|
| 37 |
+
if uploaded_file is not None:
|
| 38 |
+
# Configure multiselects based on uploaded DataFrame columns
|
| 39 |
+
columns = list(df.columns)
|
| 40 |
+
selected_gstin = st.multiselect("GST Identification Number (GSTIN)", columns, default=columns)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
if __name__ == "__main__":
|
| 44 |
+
st.set_page_config(layout="wide")
|
| 45 |
+
main()
|
pyproject.toml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "model-trainer"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = "Add your description here"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
requires-python = ">=3.10"
|
| 7 |
+
dependencies = [
|
| 8 |
+
"streamlit>=1.50.0",
|
| 9 |
+
]
|
uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|