Upload app.py
Browse files
app.py
CHANGED
|
@@ -36,19 +36,13 @@ h1 {
|
|
| 36 |
# Set up the Streamlit app
|
| 37 |
st.markdown(styles, unsafe_allow_html=True)
|
| 38 |
|
| 39 |
-
# Set up the Streamlit app
|
| 40 |
-
st.markdown(styles, unsafe_allow_html=True)
|
| 41 |
-
|
| 42 |
# Custom gradient title
|
| 43 |
st.markdown("<h1>CSV appender</h1>", unsafe_allow_html=True)
|
| 44 |
-
st.write("A website that is used for appending multiple
|
| 45 |
|
| 46 |
# File uploader for multiple CSV files
|
| 47 |
uploaded_files = st.file_uploader("Upload CSV files", type="csv", accept_multiple_files=True)
|
| 48 |
|
| 49 |
-
# Render the button styles
|
| 50 |
-
st.markdown(styles, unsafe_allow_html=True)
|
| 51 |
-
|
| 52 |
if uploaded_files:
|
| 53 |
# Initialize an empty list to store DataFrames
|
| 54 |
df_list = []
|
|
@@ -77,12 +71,42 @@ if uploaded_files:
|
|
| 77 |
|
| 78 |
with col1:
|
| 79 |
# Provide a download button for the merged CSV file
|
| 80 |
-
if st.button("
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
with col2:
|
| 88 |
# Provide an option to convert to Excel
|
|
@@ -92,20 +116,36 @@ if uploaded_files:
|
|
| 92 |
merged_df.to_excel(writer, index=False)
|
| 93 |
excel_output.seek(0)
|
| 94 |
|
| 95 |
-
#
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
else:
|
| 111 |
-
st.write("")
|
|
|
|
| 36 |
# Set up the Streamlit app
|
| 37 |
st.markdown(styles, unsafe_allow_html=True)
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
# Custom gradient title
|
| 40 |
st.markdown("<h1>CSV appender</h1>", unsafe_allow_html=True)
|
| 41 |
+
st.write("A website that is used for appending multiple CSV files and converting them to Excel format")
|
| 42 |
|
| 43 |
# File uploader for multiple CSV files
|
| 44 |
uploaded_files = st.file_uploader("Upload CSV files", type="csv", accept_multiple_files=True)
|
| 45 |
|
|
|
|
|
|
|
|
|
|
| 46 |
if uploaded_files:
|
| 47 |
# Initialize an empty list to store DataFrames
|
| 48 |
df_list = []
|
|
|
|
| 71 |
|
| 72 |
with col1:
|
| 73 |
# Provide a download button for the merged CSV file
|
| 74 |
+
if st.button("Convert to CSV"):
|
| 75 |
+
csv_output = BytesIO()
|
| 76 |
+
merged_df.to_csv(csv_output, index=False)
|
| 77 |
+
csv_output.seek(0)
|
| 78 |
+
|
| 79 |
+
# Define CSS styles for the button
|
| 80 |
+
button_styles = """
|
| 81 |
+
<style>
|
| 82 |
+
div.stButton > button {
|
| 83 |
+
color: #ffffff; /* Text color */
|
| 84 |
+
font-size: 50px;
|
| 85 |
+
background-image: linear-gradient(0deg, #a689f6 3%, #413bb9 61%);
|
| 86 |
+
border: none;
|
| 87 |
+
padding: 10px 20px;
|
| 88 |
+
cursor: pointer;
|
| 89 |
+
border-radius: 15px;
|
| 90 |
+
display: inline-block;
|
| 91 |
+
}
|
| 92 |
+
div.stButton > button:hover {
|
| 93 |
+
background-color: #00ff00; /* Hover background color */
|
| 94 |
+
color: #ff0000; /* Hover text color */
|
| 95 |
+
}
|
| 96 |
+
</style>
|
| 97 |
+
"""
|
| 98 |
+
|
| 99 |
+
# Render the button with the specified styles
|
| 100 |
+
st.markdown(button_styles, unsafe_allow_html=True)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
st.download_button(
|
| 105 |
+
label="Download Merged CSV File",
|
| 106 |
+
data=csv_output,
|
| 107 |
+
file_name="merged_data.csv",
|
| 108 |
+
mime="text/csv"
|
| 109 |
+
)
|
| 110 |
|
| 111 |
with col2:
|
| 112 |
# Provide an option to convert to Excel
|
|
|
|
| 116 |
merged_df.to_excel(writer, index=False)
|
| 117 |
excel_output.seek(0)
|
| 118 |
|
| 119 |
+
# Define CSS styles for the button
|
| 120 |
+
button_styles = """
|
| 121 |
+
<style>
|
| 122 |
+
div.stButton > button {
|
| 123 |
+
color: #ffffff; /* Text color */
|
| 124 |
+
font-size: 50px;
|
| 125 |
+
background-image: linear-gradient(0deg, #a689f6 3%, #413bb9 61%);
|
| 126 |
+
border: none;
|
| 127 |
+
padding: 10px 20px;
|
| 128 |
+
cursor: pointer;
|
| 129 |
+
border-radius: 15px;
|
| 130 |
+
display: inline-block;
|
| 131 |
+
}
|
| 132 |
+
div.stButton > button:hover {
|
| 133 |
+
background-color: #00ff00; /* Hover background color */
|
| 134 |
+
color: #ff0000; /* Hover text color */
|
| 135 |
+
}
|
| 136 |
+
</style>
|
| 137 |
+
"""
|
| 138 |
+
|
| 139 |
+
# Render the button with the specified styles
|
| 140 |
+
st.markdown(button_styles, unsafe_allow_html=True)
|
| 141 |
+
|
| 142 |
+
# Provide a download button for the Excel file
|
| 143 |
+
st.download_button(
|
| 144 |
+
label="Download Excel",
|
| 145 |
+
data=excel_output,
|
| 146 |
+
file_name="merged_data.xlsx",
|
| 147 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| 148 |
+
)
|
| 149 |
|
| 150 |
else:
|
| 151 |
+
st.write(" ")
|