Update app.py
Browse files
app.py
CHANGED
@@ -45,20 +45,19 @@ tab1, tab2, tab3 = st.tabs(["π Load Data", "π Tagged ETDs", "π Download
|
|
45 |
|
46 |
with tab1:
|
47 |
#===load data===
|
48 |
-
|
49 |
if uploaded_file is not None:
|
50 |
-
|
51 |
-
|
52 |
|
53 |
with tab2:
|
54 |
#===tagged ETDs===
|
55 |
# Tag the "Abstract" column with the corresponding categories
|
56 |
|
57 |
if uploaded_file is not None:
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
# Function to predict the category for a given abstract
|
64 |
def predict_category(abstract):
|
@@ -73,7 +72,7 @@ with tab3:
|
|
73 |
# Create a download button
|
74 |
|
75 |
if st.sidebar.button("Download"):
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
45 |
|
46 |
with tab1:
|
47 |
#===load data===
|
|
|
48 |
if uploaded_file is not None:
|
49 |
+
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
50 |
+
st.dataframe(df)
|
51 |
|
52 |
with tab2:
|
53 |
#===tagged ETDs===
|
54 |
# Tag the "Abstract" column with the corresponding categories
|
55 |
|
56 |
if uploaded_file is not None:
|
57 |
+
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
58 |
+
st.dataframe(df)
|
59 |
+
df['category'] = df['Abstract'].apply(predict_category)
|
60 |
+
st.dataframe(df)
|
61 |
|
62 |
# Function to predict the category for a given abstract
|
63 |
def predict_category(abstract):
|
|
|
72 |
# Create a download button
|
73 |
|
74 |
if st.sidebar.button("Download"):
|
75 |
+
csv = df.to_csv(index=False)
|
76 |
+
b64 = base64.b64encode(csv.encode()).decode()
|
77 |
+
href = f'<a href="data:file/csv;base64,{b64}" download="results.csv">Download csv file</a>'
|
78 |
+
st.markdown(href, unsafe_allow_html=True)
|