Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,24 @@
|
|
|
|
1 |
import zipfile
|
2 |
import os
|
3 |
|
4 |
-
#
|
5 |
-
zip_file_path
|
|
|
|
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
|
|
9 |
|
10 |
-
|
11 |
-
if not os.path.exists(extract_to_path):
|
12 |
-
os.makedirs(extract_to_path)
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
import zipfile
|
3 |
import os
|
4 |
|
5 |
+
# Function to unzip the 'cspc_db.zip' file and save it in the 'cspc_db' folder
|
6 |
+
def unzip_file(zip_file_path, extract_to_path):
|
7 |
+
# Check if the destination directory exists, and if not, create it
|
8 |
+
if not os.path.exists(extract_to_path):
|
9 |
+
os.makedirs(extract_to_path)
|
10 |
|
11 |
+
# Unzip the file
|
12 |
+
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
|
13 |
+
zip_ref.extractall(extract_to_path)
|
14 |
|
15 |
+
st.success(f"Files have been extracted to: {extract_to_path}")
|
|
|
|
|
16 |
|
17 |
+
# Define the path for the zip file and the extraction folder
|
18 |
+
zip_file_path = "cspc_db.zip"
|
19 |
+
extract_to_path = "cspc_db"
|
20 |
|
21 |
+
# Add a button to trigger the unzip process
|
22 |
+
if st.button('Unzip CSPC Database'):
|
23 |
+
unzip_file(zip_file_path, extract_to_path)
|
24 |
+
st.write(f"Unzipped files are available in the '{extract_to_path}' folder.")
|