Nioooor commited on
Commit
aeb23ed
·
verified ·
1 Parent(s): ada6443

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -1,18 +1,24 @@
 
1
  import zipfile
2
  import os
3
 
4
- # Specify the path to the .zip file
5
- zip_file_path = "cspc_db.zip"
 
 
 
6
 
7
- # Specify the directory where you want to extract the files
8
- extract_to_path = "cspc_db"
 
9
 
10
- # Check if the destination directory exists, and if not, create it
11
- if not os.path.exists(extract_to_path):
12
- os.makedirs(extract_to_path)
13
 
14
- # Unzip the file
15
- with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
16
- zip_ref.extractall(extract_to_path)
17
 
18
- print(f"Files have been extracted to: {extract_to_path}")
 
 
 
 
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.")