Upload 2 files
Browse files- app.py +112 -0
- requirements.txt +171 -0
app.py
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from io import BytesIO
|
| 4 |
+
|
| 5 |
+
# Define the button and title styles
|
| 6 |
+
styles = """
|
| 7 |
+
<style>
|
| 8 |
+
/* Button styles */
|
| 9 |
+
div.stButton > button {
|
| 10 |
+
color: #ffffff; /* Text color */
|
| 11 |
+
font-size: 20px;
|
| 12 |
+
background-image: linear-gradient(0deg, #a2c2e1 0%, #003b5c 100%); /* Light blue to deep blue gradient */
|
| 13 |
+
border: none;
|
| 14 |
+
padding: 10px 20px;
|
| 15 |
+
cursor: pointer;
|
| 16 |
+
border-radius: 15px;
|
| 17 |
+
display: inline-block;
|
| 18 |
+
width: 100%; /* Make button fit column width */
|
| 19 |
+
}
|
| 20 |
+
div.stButton > button:hover {
|
| 21 |
+
background-color: #00ff00; /* Hover background color */
|
| 22 |
+
color: #ff0000; /* Hover text color */
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* Title styles */
|
| 26 |
+
h1 {
|
| 27 |
+
background-image: linear-gradient(0deg, #a2c2e1 0%, #003b5c 100%); /* Light blue to deep blue gradient */
|
| 28 |
+
-webkit-background-clip: text;
|
| 29 |
+
-webkit-text-fill-color: transparent;
|
| 30 |
+
font-size: 36px;
|
| 31 |
+
}
|
| 32 |
+
</style>
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
# Set up the Streamlit app
|
| 36 |
+
st.markdown(styles, unsafe_allow_html=True)
|
| 37 |
+
|
| 38 |
+
# Custom gradient title
|
| 39 |
+
st.markdown("<h1>CSV and Excel Appender</h1>", unsafe_allow_html=True)
|
| 40 |
+
st.write("A website that is used for appending multiple CSV and Excel files and converting them to a desired format.")
|
| 41 |
+
|
| 42 |
+
# File uploader for multiple CSV and Excel files
|
| 43 |
+
uploaded_files = st.file_uploader("Upload CSV or Excel files", type=["csv", "xlsx"], accept_multiple_files=True)
|
| 44 |
+
|
| 45 |
+
if uploaded_files:
|
| 46 |
+
# Initialize an empty list to store DataFrames
|
| 47 |
+
df_list = []
|
| 48 |
+
|
| 49 |
+
for i, uploaded_file in enumerate(uploaded_files):
|
| 50 |
+
# Get the file name without extension
|
| 51 |
+
file_name = uploaded_file.name
|
| 52 |
+
|
| 53 |
+
# Check the file type and read accordingly
|
| 54 |
+
if uploaded_file.type == "text/csv":
|
| 55 |
+
if i == 0:
|
| 56 |
+
# For the first file, include the header
|
| 57 |
+
df = pd.read_csv(uploaded_file)
|
| 58 |
+
# Store the columns from the first file
|
| 59 |
+
headers = df.columns
|
| 60 |
+
else:
|
| 61 |
+
# For subsequent files, set the header using the stored headers
|
| 62 |
+
df = pd.read_csv(uploaded_file, names=headers, header=0)
|
| 63 |
+
elif uploaded_file.type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
| 64 |
+
if i == 0:
|
| 65 |
+
# For the first file, include the header
|
| 66 |
+
df = pd.read_excel(uploaded_file)
|
| 67 |
+
# Store the columns from the first file
|
| 68 |
+
headers = df.columns
|
| 69 |
+
else:
|
| 70 |
+
# For subsequent files, set the header using the stored headers
|
| 71 |
+
df = pd.read_excel(uploaded_file, names=headers, header=0)
|
| 72 |
+
|
| 73 |
+
# Add a column for the file name
|
| 74 |
+
df['file_name'] = file_name
|
| 75 |
+
df_list.append(df)
|
| 76 |
+
|
| 77 |
+
# Concatenate all DataFrames, ignoring index to avoid duplication
|
| 78 |
+
merged_df = pd.concat(df_list, ignore_index=True)
|
| 79 |
+
|
| 80 |
+
# Display the merged DataFrame
|
| 81 |
+
st.markdown("<h1>Appended Data</h1>", unsafe_allow_html=True)
|
| 82 |
+
st.dataframe(merged_df)
|
| 83 |
+
|
| 84 |
+
# Create a layout with 3 columns for buttons
|
| 85 |
+
col1, col2, col3 = st.columns(3)
|
| 86 |
+
|
| 87 |
+
with col1:
|
| 88 |
+
# Provide a download button for the merged CSV file
|
| 89 |
+
csv_output = BytesIO()
|
| 90 |
+
merged_df.to_csv(csv_output, index=False)
|
| 91 |
+
csv_output.seek(0)
|
| 92 |
+
st.download_button(
|
| 93 |
+
label="Download Merged CSV File",
|
| 94 |
+
data=csv_output,
|
| 95 |
+
file_name="merged_data.csv",
|
| 96 |
+
mime="text/csv"
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
with col2:
|
| 100 |
+
# Provide an option to convert to Excel
|
| 101 |
+
excel_output = BytesIO()
|
| 102 |
+
with pd.ExcelWriter(excel_output, engine='xlsxwriter') as writer:
|
| 103 |
+
merged_df.to_excel(writer, index=False)
|
| 104 |
+
excel_output.seek(0)
|
| 105 |
+
st.download_button(
|
| 106 |
+
label="Download Merged Excel File",
|
| 107 |
+
data=excel_output,
|
| 108 |
+
file_name="merged_data.xlsx",
|
| 109 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
| 110 |
+
)
|
| 111 |
+
else:
|
| 112 |
+
st.write("")
|
requirements.txt
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
absl-py==2.1.0
|
| 2 |
+
aiohttp==3.9.5
|
| 3 |
+
aiohttp-retry==2.8.3
|
| 4 |
+
aiosignal==1.3.1
|
| 5 |
+
altair==4.2.2
|
| 6 |
+
annotated-types==0.7.0
|
| 7 |
+
anyio==4.4.0
|
| 8 |
+
APScheduler==3.10.4
|
| 9 |
+
astunparse==1.6.3
|
| 10 |
+
async-timeout==4.0.3
|
| 11 |
+
attrs==23.2.0
|
| 12 |
+
beautifulsoup4==4.12.3
|
| 13 |
+
blinker==1.8.2
|
| 14 |
+
cachetools==5.3.3
|
| 15 |
+
cairocffi==1.7.1
|
| 16 |
+
CairoSVG==2.7.1
|
| 17 |
+
certifi==2024.6.2
|
| 18 |
+
cffi==1.16.0
|
| 19 |
+
charset-normalizer==3.3.2
|
| 20 |
+
click==8.1.7
|
| 21 |
+
cloudevents==1.11.0
|
| 22 |
+
contourpy==1.2.1
|
| 23 |
+
css==0.1
|
| 24 |
+
cssselect2==0.7.0
|
| 25 |
+
cycler==0.12.1
|
| 26 |
+
db-dtypes==1.2.0
|
| 27 |
+
defusedxml==0.7.1
|
| 28 |
+
deprecation==2.1.0
|
| 29 |
+
distro==1.9.0
|
| 30 |
+
entrypoints==0.4
|
| 31 |
+
et-xmlfile==1.1.0
|
| 32 |
+
exceptiongroup==1.2.1
|
| 33 |
+
filelock==3.15.4
|
| 34 |
+
Flask==3.0.3
|
| 35 |
+
flatbuffers==24.3.25
|
| 36 |
+
fonttools==4.53.1
|
| 37 |
+
fpdf==1.7.2
|
| 38 |
+
frozenlist==1.4.1
|
| 39 |
+
fsspec==2024.6.1
|
| 40 |
+
functions-framework==3.8.0
|
| 41 |
+
gast==0.6.0
|
| 42 |
+
gitdb==4.0.11
|
| 43 |
+
GitPython==3.1.43
|
| 44 |
+
google-api-core==2.19.0
|
| 45 |
+
google-auth==2.30.0
|
| 46 |
+
google-auth-oauthlib==1.2.0
|
| 47 |
+
google-cloud==0.34.0
|
| 48 |
+
google-cloud-bigquery==3.24.0
|
| 49 |
+
google-cloud-core==2.4.1
|
| 50 |
+
google-crc32c==1.5.0
|
| 51 |
+
google-pasta==0.2.0
|
| 52 |
+
google-resumable-media==2.7.1
|
| 53 |
+
googleapis-common-protos==1.63.1
|
| 54 |
+
grpcio==1.64.1
|
| 55 |
+
grpcio-status==1.62.2
|
| 56 |
+
gspread==6.1.2
|
| 57 |
+
gunicorn==22.0.0
|
| 58 |
+
h11==0.14.0
|
| 59 |
+
h5py==3.11.0
|
| 60 |
+
httpcore==1.0.5
|
| 61 |
+
httplib2==0.22.0
|
| 62 |
+
httpx==0.27.0
|
| 63 |
+
huggingface-hub==0.24.1
|
| 64 |
+
idna==3.7
|
| 65 |
+
importlib_metadata==8.0.0
|
| 66 |
+
importlib_resources==6.4.0
|
| 67 |
+
itsdangerous==2.2.0
|
| 68 |
+
Jinja2==3.1.4
|
| 69 |
+
jsonschema==4.22.0
|
| 70 |
+
jsonschema-specifications==2023.12.1
|
| 71 |
+
keras==3.4.1
|
| 72 |
+
kiwisolver==1.4.5
|
| 73 |
+
libclang==18.1.1
|
| 74 |
+
lxml==5.2.2
|
| 75 |
+
Markdown==3.6
|
| 76 |
+
markdown-it-py==3.0.0
|
| 77 |
+
MarkupSafe==2.1.5
|
| 78 |
+
matplotlib==3.9.1
|
| 79 |
+
mdurl==0.1.2
|
| 80 |
+
ml-dtypes==0.4.0
|
| 81 |
+
mpmath==1.3.0
|
| 82 |
+
multidict==6.0.5
|
| 83 |
+
namex==0.0.8
|
| 84 |
+
networkx==3.2.1
|
| 85 |
+
ngrok==1.3.0
|
| 86 |
+
numpy==1.26.4
|
| 87 |
+
oauth2client==4.1.3
|
| 88 |
+
oauthlib==3.2.2
|
| 89 |
+
openai==1.37.1
|
| 90 |
+
openpyxl==3.1.4
|
| 91 |
+
opt-einsum==3.3.0
|
| 92 |
+
optree==0.12.1
|
| 93 |
+
outcome==1.3.0.post0
|
| 94 |
+
packaging==24.1
|
| 95 |
+
pandas==2.2.2
|
| 96 |
+
pillow==10.3.0
|
| 97 |
+
proto-plus==1.24.0
|
| 98 |
+
protobuf==4.25.3
|
| 99 |
+
pyarrow==16.1.0
|
| 100 |
+
pyasn1==0.6.0
|
| 101 |
+
pyasn1_modules==0.4.0
|
| 102 |
+
pycparser==2.22
|
| 103 |
+
pydantic==2.8.2
|
| 104 |
+
pydantic_core==2.20.1
|
| 105 |
+
pydeck==0.9.1
|
| 106 |
+
Pygments==2.18.0
|
| 107 |
+
PyJWT==2.8.0
|
| 108 |
+
pyngrok==7.2.0
|
| 109 |
+
pyparsing==3.1.2
|
| 110 |
+
PyPDF2==3.0.1
|
| 111 |
+
PySocks==1.7.1
|
| 112 |
+
pytesseract==0.3.10
|
| 113 |
+
python-dateutil==2.9.0.post0
|
| 114 |
+
python-decouple==3.8
|
| 115 |
+
python-docx==1.1.2
|
| 116 |
+
python-dotenv==1.0.1
|
| 117 |
+
pytz==2024.1
|
| 118 |
+
PyYAML==6.0.1
|
| 119 |
+
referencing==0.35.1
|
| 120 |
+
regex==2024.5.15
|
| 121 |
+
requests==2.32.3
|
| 122 |
+
requests-oauthlib==2.0.0
|
| 123 |
+
rich==13.7.1
|
| 124 |
+
rpds-py==0.18.1
|
| 125 |
+
rsa==4.9
|
| 126 |
+
safetensors==0.4.3
|
| 127 |
+
schedule==1.2.2
|
| 128 |
+
selenium==4.22.0
|
| 129 |
+
six==1.16.0
|
| 130 |
+
smmap==5.0.1
|
| 131 |
+
sniffio==1.3.1
|
| 132 |
+
sortedcontainers==2.4.0
|
| 133 |
+
soupsieve==2.5
|
| 134 |
+
streamlit==1.37.0
|
| 135 |
+
streamlit-aggrid==1.0.5
|
| 136 |
+
streamlit-option-menu==0.3.13
|
| 137 |
+
streamlit-space==0.1.5
|
| 138 |
+
streamlit-toggle==0.1.3
|
| 139 |
+
streamlit-toggle-switch==1.0.2
|
| 140 |
+
sympy==1.13.1
|
| 141 |
+
tenacity==8.3.0
|
| 142 |
+
tensorboard==2.17.0
|
| 143 |
+
tensorboard-data-server==0.7.2
|
| 144 |
+
tensorflow==2.17.0
|
| 145 |
+
tensorflow-io-gcs-filesystem==0.37.1
|
| 146 |
+
termcolor==2.4.0
|
| 147 |
+
tf_keras==2.17.0
|
| 148 |
+
tinycss2==1.3.0
|
| 149 |
+
tokenizers==0.19.1
|
| 150 |
+
toml==0.10.2
|
| 151 |
+
toolz==0.12.1
|
| 152 |
+
torch==2.4.0
|
| 153 |
+
tornado==6.4.1
|
| 154 |
+
tqdm==4.66.4
|
| 155 |
+
transformers==4.43.3
|
| 156 |
+
trio==0.25.1
|
| 157 |
+
trio-websocket==0.11.1
|
| 158 |
+
twilio==9.2.3
|
| 159 |
+
typing_extensions==4.12.2
|
| 160 |
+
tzdata==2024.1
|
| 161 |
+
tzlocal==5.2
|
| 162 |
+
urllib3==2.2.2
|
| 163 |
+
watchdog==4.0.1
|
| 164 |
+
webencodings==0.5.1
|
| 165 |
+
websocket-client==1.8.0
|
| 166 |
+
Werkzeug==3.0.3
|
| 167 |
+
wrapt==1.16.0
|
| 168 |
+
wsproto==1.2.0
|
| 169 |
+
XlsxWriter==3.2.0
|
| 170 |
+
yarl==1.9.4
|
| 171 |
+
zipp==3.19.2
|