Spaces:
Sleeping
Sleeping
import json | |
# from pathlib import Path | |
from PIL import Image | |
import pandas as pd | |
import streamlit as st | |
from arabic_support import support_arabic_text | |
import config.handling | |
from config.handling import * | |
current_file_path = Path(__file__).resolve() | |
project_root = current_file_path.parents[1] | |
assets_dir = project_root / "asset" | |
database_dir = project_root / "data" | |
styles_dir = project_root / "styles" | |
st.set_page_config( | |
page_title="Upload Data", | |
page_icon="📝", | |
layout="wide", | |
initial_sidebar_state="expanded", | |
) | |
# Support Arabic text alignment in all components | |
support_arabic_text(all=True) | |
# Reading CSS from file | |
with open(styles_dir / "main.css", "r") as file: | |
css_code = file.read() | |
# Applying CSS | |
st.markdown(f"<style>{css_code}</style>", unsafe_allow_html=True) | |
side = st.sidebar | |
with side: | |
img = Image.open(assets_dir / "robot.png") | |
st.image(img, width=250, caption="بارگذاری داده ها") | |
st.title("بارگذاری در پایگاه داده") | |
uploaded_file = st.file_uploader( | |
"Choose a XLSX file", type=["xlsx"], accept_multiple_files=False | |
) | |
if uploaded_file is not None: | |
df = pd.read_excel(uploaded_file) | |
df = config.handling.data_cleaning(df) | |
df2 = data_cleaning(df) | |
quiz = quiz_maker(df2) | |
option = option_maker(df2) | |
df2.to_csv(database_dir / "data5.csv", index=False) | |
# st.write("filename:", uploaded_file.name) | |
df2 = pd.read_csv(database_dir / "data5.csv") | |
st.data_editor(df2) |