Update app.py
Browse files
app.py
CHANGED
@@ -73,20 +73,21 @@ def conv_txt(extype):
|
|
73 |
|
74 |
#===Read data===
|
75 |
uploaded_file = st.file_uploader("Choose a file", type=['csv'])
|
76 |
-
|
|
|
77 |
if uploaded_file is not None:
|
78 |
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
79 |
st.dataframe(df)
|
|
|
80 |
# Tag the "Abstract" column with the corresponding categories
|
81 |
-
df['category'] = df['Abstract'].apply(predict_category)
|
82 |
st.dataframe(df)
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
st.markdown(href, unsafe_allow_html=True)
|
|
|
73 |
|
74 |
#===Read data===
|
75 |
uploaded_file = st.file_uploader("Choose a file", type=['csv'])
|
76 |
+
st.sidebar.header("Download Results")
|
77 |
+
st.sidebar.text("Download the tagged results as a CSV file.")
|
78 |
if uploaded_file is not None:
|
79 |
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
80 |
st.dataframe(df)
|
81 |
+
|
82 |
# Tag the "Abstract" column with the corresponding categories
|
83 |
+
df['category'] = df['Abstract'].apply(lambda x: predict_category(x)[0])
|
84 |
st.dataframe(df)
|
85 |
+
|
86 |
+
csv = df.to_csv(index=False, encoding='utf-8-sig') # Using utf-8-sig to handle possible BOM issues
|
87 |
+
b64 = base64.b64encode(csv.encode('utf-8-sig'))
|
88 |
+
st.sidebar.download_button(
|
89 |
+
label="Download",
|
90 |
+
data=b64,
|
91 |
+
file_name="results.csv",
|
92 |
+
mime="text/csv"
|
93 |
+
)
|
|