Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -86,23 +86,31 @@ if file is not None:
|
|
86 |
.to_html(index=False, escape=False))
|
87 |
|
88 |
# Wrap the table inside a div with a fixed height and scrollable content
|
89 |
-
|
90 |
-
# Display the table with a fixed header and scrollable content
|
91 |
-
st.write(df, unsafe_allow_html=True, max_rows=max_rows, header=True, scrollable=True, sticky_header=True)
|
92 |
|
93 |
def convert_df(df):
|
94 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
95 |
return df.to_csv().encode('utf-8')
|
96 |
|
97 |
csv = convert_df(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
# Add some space between the download button and the table
|
100 |
st.write("<br><br>", unsafe_allow_html=True)
|
101 |
|
|
|
|
|
102 |
st.download_button(
|
103 |
label="Download data as CSV",
|
104 |
data=csv,
|
105 |
file_name='Review Sentiments.csv',
|
|
|
106 |
)
|
|
|
107 |
else:
|
108 |
st.write("Please upload the reviews as a CSV file.")
|
|
|
86 |
.to_html(index=False, escape=False))
|
87 |
|
88 |
# Wrap the table inside a div with a fixed height and scrollable content
|
89 |
+
st.write(f'<div style="height: {max_rows*30}px; overflow-y: scroll;">{table_html}</div>', unsafe_allow_html=True,header=True,sticky_header=True)
|
|
|
|
|
90 |
|
91 |
def convert_df(df):
|
92 |
# IMPORTANT: Cache the conversion to prevent computation on every rerun
|
93 |
return df.to_csv().encode('utf-8')
|
94 |
|
95 |
csv = convert_df(df)
|
96 |
+
|
97 |
+
css = """
|
98 |
+
.css-1irvrzc:hover, .css-1irvrzc:active {
|
99 |
+
background-color: #4AA6DD !important;
|
100 |
+
}
|
101 |
+
"""
|
102 |
|
103 |
# Add some space between the download button and the table
|
104 |
st.write("<br><br>", unsafe_allow_html=True)
|
105 |
|
106 |
+
st.write(f'<style>{css}</style>', unsafe_allow_html=True)
|
107 |
+
|
108 |
st.download_button(
|
109 |
label="Download data as CSV",
|
110 |
data=csv,
|
111 |
file_name='Review Sentiments.csv',
|
112 |
+
border_color='#4AA6DD'
|
113 |
)
|
114 |
+
|
115 |
else:
|
116 |
st.write("Please upload the reviews as a CSV file.")
|