Update app.py
Browse files
app.py
CHANGED
@@ -42,18 +42,22 @@ st.title("About")
|
|
42 |
st.subheader("You can tag your input CSV file of theses and dissertations with Library Science, Archival Studies, and Information Science categories. The screen will show the output.")
|
43 |
|
44 |
tab1, tab2, tab3 = st.tabs(["π Load Data", "π Tagged ETDs", "π Download Data"])
|
|
|
45 |
with tab1:
|
46 |
#===load data===
|
47 |
-
|
48 |
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
49 |
st.dataframe(df)
|
50 |
-
|
51 |
-
|
52 |
with tab2:
|
53 |
#===tagged ETDs===
|
54 |
# Tag the "Abstract" column with the corresponding categories
|
|
|
|
|
|
|
55 |
df['category'] = df['Abstract'].apply(predict_category)
|
56 |
st.dataframe(df)
|
|
|
57 |
# Function to predict the category for a given abstract
|
58 |
def predict_category(abstract):
|
59 |
# Preprocess the abstract
|
@@ -65,7 +69,7 @@ def predict_category(abstract):
|
|
65 |
with tab3:
|
66 |
#===download result===
|
67 |
# Create a download button
|
68 |
-
|
69 |
csv = df.to_csv(index=False)
|
70 |
b64 = base64.b64encode(csv.encode()).decode()
|
71 |
href = f'<a href="data:file/csv;base64,{b64}" download="results.csv">Download csv file</a>'
|
|
|
42 |
st.subheader("You can tag your input CSV file of theses and dissertations with Library Science, Archival Studies, and Information Science categories. The screen will show the output.")
|
43 |
|
44 |
tab1, tab2, tab3 = st.tabs(["π Load Data", "π Tagged ETDs", "π Download Data"])
|
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 |
+
if uploaded_file is not None:
|
56 |
+
df = pd.read_csv(uploaded_file, encoding='latin-1')
|
57 |
+
st.dataframe(df)
|
58 |
df['category'] = df['Abstract'].apply(predict_category)
|
59 |
st.dataframe(df)
|
60 |
+
|
61 |
# Function to predict the category for a given abstract
|
62 |
def predict_category(abstract):
|
63 |
# Preprocess the abstract
|
|
|
69 |
with tab3:
|
70 |
#===download result===
|
71 |
# Create a download button
|
72 |
+
if st.sidebar.button("Download"):
|
73 |
csv = df.to_csv(index=False)
|
74 |
b64 = base64.b64encode(csv.encode()).decode()
|
75 |
href = f'<a href="data:file/csv;base64,{b64}" download="results.csv">Download csv file</a>'
|