Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -73,6 +73,7 @@ from PyPDFForm import FormWrapper
|
|
| 73 |
|
| 74 |
import os
|
| 75 |
|
|
|
|
| 76 |
# Get the current working directory
|
| 77 |
current_folder = os.getcwd()
|
| 78 |
#Variables Initialization
|
|
@@ -1209,6 +1210,9 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
| 1209 |
# Create a PDF for each row
|
| 1210 |
create_pdf(row['COMPANY'], row['EMPLOYEE NAME'], row['ACCOUNT NUMBER'],directory)
|
| 1211 |
create_document = False
|
|
|
|
|
|
|
|
|
|
| 1212 |
docstatus = f"Please download the complete dataset here: <a href='https://redmindtechnologies.com/RedMindGPT/output.zip' download>Download</a>. {total_rows} documents are created successfully."
|
| 1213 |
print(sample_table)
|
| 1214 |
# 5. Return the summary and downloadable link
|
|
@@ -1268,6 +1272,19 @@ def create_pdf(cname,ename,account_number, directory):
|
|
| 1268 |
|
| 1269 |
return f"{output_file_name} is created successfully."
|
| 1270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1271 |
|
| 1272 |
def directory_exists(repo_id, directory, token):
|
| 1273 |
try:
|
|
|
|
| 73 |
|
| 74 |
import os
|
| 75 |
|
| 76 |
+
import zipfile
|
| 77 |
# Get the current working directory
|
| 78 |
current_folder = os.getcwd()
|
| 79 |
#Variables Initialization
|
|
|
|
| 1210 |
# Create a PDF for each row
|
| 1211 |
create_pdf(row['COMPANY'], row['EMPLOYEE NAME'], row['ACCOUNT NUMBER'],directory)
|
| 1212 |
create_document = False
|
| 1213 |
+
zip_name = 'output_files.zip'
|
| 1214 |
+
zip_files_in_folder(directory, zip_name)
|
| 1215 |
+
create_file_HF(zip_name,directory, False)
|
| 1216 |
docstatus = f"Please download the complete dataset here: <a href='https://redmindtechnologies.com/RedMindGPT/output.zip' download>Download</a>. {total_rows} documents are created successfully."
|
| 1217 |
print(sample_table)
|
| 1218 |
# 5. Return the summary and downloadable link
|
|
|
|
| 1272 |
|
| 1273 |
return f"{output_file_name} is created successfully."
|
| 1274 |
|
| 1275 |
+
def zip_files_in_folder(folder_path, zip_name):
|
| 1276 |
+
# Create a Zip file
|
| 1277 |
+
folder_path="./"
|
| 1278 |
+
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
| 1279 |
+
# Walk through the folder
|
| 1280 |
+
for root, dirs, files in os.walk(folder_path):
|
| 1281 |
+
for file in files:
|
| 1282 |
+
file_path = os.path.join(root, file)
|
| 1283 |
+
# Add each file to the zip file
|
| 1284 |
+
zipf.write(file_path, os.path.relpath(file_path, folder_path))
|
| 1285 |
+
|
| 1286 |
+
print(f"Zip file '{zip_name}' created successfully!")
|
| 1287 |
+
|
| 1288 |
|
| 1289 |
def directory_exists(repo_id, directory, token):
|
| 1290 |
try:
|