From c87308cc21f36963f8cfff5735e5a25b5c0afd64 Mon Sep 17 00:00:00 2001 From: clfreville2 Date: Fri, 21 Jun 2024 16:46:35 +0200 Subject: [PATCH] Support multiple column delimiters --- frontend/exploration.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/exploration.py b/frontend/exploration.py index 4cac622..7c233b4 100644 --- a/frontend/exploration.py +++ b/frontend/exploration.py @@ -1,5 +1,6 @@ import pandas as pd import streamlit as st +import codecs st.set_page_config( page_title="Project Miner", @@ -9,10 +10,13 @@ st.set_page_config( st.title("Home") ### Exploration -uploaded_file = st.file_uploader("Upload your CSV file", type=["csv"]) +uploaded_file = st.file_uploader("Upload your CSV file", type=["csv", "tsv"]) +separator = st.selectbox("Separator", [",", ";", "\\t"]) +separator = codecs.getdecoder("unicode_escape")(separator)[0] +has_header = st.checkbox("Has header", value=True) if uploaded_file is not None: - st.session_state.data = pd.read_csv(uploaded_file) + st.session_state.data = pd.read_csv(uploaded_file, sep=separator, header=0 if has_header else 1) st.session_state.original_data = st.session_state.data st.success("File loaded successfully!")