Davide Fiocco commited on
Commit
2b07bf2
·
1 Parent(s): a452638

Debug download button

Browse files
Files changed (1) hide show
  1. app.py +15 -21
app.py CHANGED
@@ -46,30 +46,24 @@ labels = st.text_input("Enter comma-separated labels:")
46
 
47
  if st.button("Calculate labels"):
48
 
49
- try:
50
- labels_list = labels.split(",")
51
- table = pd.read_excel(data)
52
- table = table.loc[table["text"].apply(len) > 10].reset_index(drop=True)
53
 
54
- prog_bar = st.progress(0)
55
- preds = []
56
 
57
- for i in range(len(table)):
58
- preds.append(classifier(table.loc[i, "text"], labels)["labels"][0])
59
- prog_bar.progress((i + 1) / len(table))
60
 
61
- table["label"] = preds
62
 
63
- st.table(table[["text", "label"]])
64
 
65
- buf = BytesIO()
66
- table[["text", "label"]].to_excel(buf)
67
 
68
- st.download_button(
69
- label="Download table", data=buf.getvalue(), file_name="output.xlsx"
70
- )
71
-
72
- except:
73
- st.error(
74
- "Something went wrong. Make sure you upload an Excel file containing a column named `text` and a set of comma-separated labels is provided"
75
- )
 
46
 
47
  if st.button("Calculate labels"):
48
 
49
+ labels_list = labels.split(",")
50
+ table = pd.read_excel(data)
51
+ table = table.loc[table["text"].apply(len) > 10].reset_index(drop=True)
 
52
 
53
+ prog_bar = st.progress(0)
54
+ preds = []
55
 
56
+ for i in range(len(table)):
57
+ preds.append(classifier(table.loc[i, "text"], labels)["labels"][0])
58
+ prog_bar.progress((i + 1) / len(table))
59
 
60
+ table["label"] = preds
61
 
62
+ st.table(table[["text", "label"]])
63
 
64
+ buf = BytesIO()
65
+ table[["text", "label"]].to_excel(buf)
66
 
67
+ st.download_button(
68
+ label="Download table", data=buf.getvalue(), file_name="output.xlsx"
69
+ )