Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import os | |
| import json | |
| import csv | |
| # import sys | |
| # sys.path.append('scripts/') | |
| from visualization import st_data_visualization | |
| from feature_select import st_feature_selection | |
| from classification import st_classification | |
| from data_clean import handle_missing_value | |
| def try_read_df(f, f_name): | |
| filename, file_extension = os.path.splitext(f_name) | |
| try: | |
| if file_extension.startswith(".xls"): | |
| return pd.read_excel(f) | |
| elif file_extension.endswith(".csv"): | |
| return pd.read_csv(f) | |
| elif file_extension.endswith('.json'): | |
| return pd.read_json(f) | |
| else: | |
| st.write("File Type did not match") | |
| except Exception as e: | |
| st.write(e) | |
| def main(): | |
| st.write("This is a Data Science App for Data Visualization, Data Cleaning, Feature Selection and Classification") | |
| st.subheader("How to use the app") | |
| #procedure to upload and use other functions | |
| st.write("- Use left side bar that says browse, to upload the files.") | |
| st.write("- Upload a CSV/Excel file and then choose the functionality you want to use.") | |
| st.write("- Use side bar to navigate to other functionalities.") | |
| st.write("- The file will be deleted after the session is closed.") | |
| st.write("The app is still in development phase.") | |
| st.write("This App is built by Rahul Parajuli.") | |
| st.subheader("Start by uploading and see the results below - ") | |
| st.write("There is also a sample file 'Titanic Dataset' in the program so go ahead and press on app functionality and choose data visualization") | |
| # SideBar Settings | |
| st.sidebar.title("Automatic Data Science App") | |
| st.sidebar.info( | |
| "The Byte Factory" | |
| ) | |
| # app functionalities | |
| primary_function = st.sidebar.selectbox( | |
| 'Choose App Functionality', ["Upload CSV File", "Data Visualization", \ | |
| "Data Cleanup", "Feature Selection", "Classification"]) | |
| if primary_function == "Upload CSV File": | |
| uploaded_file = st.sidebar.file_uploader("Upload a CSV/Excel file", accept_multiple_files=False,\ | |
| type=("csv", "xls", "json")) | |
| if uploaded_file is not None: | |
| data = try_read_df(uploaded_file, uploaded_file.name) | |
| st.write("Here are the first ten rows of the File") | |
| st.table(data.head(10)) | |
| file_details = {"FileName":uploaded_file.name,"FileType":uploaded_file.type,\ | |
| "FileSize":uploaded_file.size} | |
| st.sidebar.write(file_details) | |
| with open(os.path.join("temp_data", "test.csv"), "wb") as f: | |
| f.write(uploaded_file.getbuffer()) | |
| if primary_function == "Data Visualization": | |
| st_data_visualization() | |
| if primary_function == "Data Cleanup": | |
| handle_missing_value() | |
| if primary_function == "Feature Selection": | |
| st_feature_selection() | |
| if primary_function == "Classification": | |
| st_classification() | |
| # data_visualization = st.sidebar.button("Visualize Data") | |
| # data_cleanup = st.sidebar.button("Clean Data") | |
| # feature_selection = st.sidebar.button("Feature Selection") | |
| # classification = st.sidebar.button("Classification") | |
| # if data_visualization: | |
| # st_data_visualization() | |
| # if data_cleanup: | |
| # handle_missing_value() | |
| # if feature_selection: | |
| # st_feature_selection() | |
| # if classification: | |
| # st_classification() | |
| if __name__ == '__main__': | |
| main() | |