Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1210,10 +1210,13 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1210 |
# Create a PDF for each row
|
1211 |
create_pdf(row['COMPANY'], row['EMPLOYEE NAME'], row['ACCOUNT NUMBER'],directory)
|
1212 |
create_document = False
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
|
|
|
|
|
|
1217 |
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."
|
1218 |
print(sample_table)
|
1219 |
# 5. Return the summary and downloadable link
|
@@ -1271,25 +1274,22 @@ def create_pdf(cname,ename,account_number, directory):
|
|
1271 |
# Get the absolute path
|
1272 |
file_path = os.path.abspath(output_file_name)
|
1273 |
print(f"The file was created at: {file_path}")
|
1274 |
-
create_file_HF(output_file_name, directory,document_created)
|
1275 |
|
1276 |
|
1277 |
return f"{output_file_name} is created successfully."
|
1278 |
|
1279 |
def zip_files_in_folder(folder_path, zip_name):
|
1280 |
-
#
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
# Walk through the folder
|
1285 |
-
for root, dirs, files in os.walk(folder_path):
|
1286 |
for file in files:
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
print(f"
|
1292 |
-
|
1293 |
|
1294 |
def directory_exists(repo_id, directory, token):
|
1295 |
try:
|
|
|
1210 |
# Create a PDF for each row
|
1211 |
create_pdf(row['COMPANY'], row['EMPLOYEE NAME'], row['ACCOUNT NUMBER'],directory)
|
1212 |
create_document = False
|
1213 |
+
# Directory containing PDF files
|
1214 |
+
pdf_dir = "/home/user/app"
|
1215 |
+
# Output ZIP file name
|
1216 |
+
zip_file_name = "/home/user/app/pdf_files.zip"
|
1217 |
+
print(zip_file_name)
|
1218 |
+
zip_files_in_folder(directory, zip_file_name)
|
1219 |
+
create_file_HF(zip_file_name,directory, False)
|
1220 |
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."
|
1221 |
print(sample_table)
|
1222 |
# 5. Return the summary and downloadable link
|
|
|
1274 |
# Get the absolute path
|
1275 |
file_path = os.path.abspath(output_file_name)
|
1276 |
print(f"The file was created at: {file_path}")
|
1277 |
+
#create_file_HF(output_file_name, directory,document_created)
|
1278 |
|
1279 |
|
1280 |
return f"{output_file_name} is created successfully."
|
1281 |
|
1282 |
def zip_files_in_folder(folder_path, zip_name):
|
1283 |
+
# Initialize the ZIP file
|
1284 |
+
with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
1285 |
+
# Walk through the directory and add PDF files to the ZIP
|
1286 |
+
for root, _, files in os.walk(directory):
|
|
|
|
|
1287 |
for file in files:
|
1288 |
+
if file.endswith(".pdf"): # Only include PDF files
|
1289 |
+
file_path = os.path.join(root, file)
|
1290 |
+
# Add file to the ZIP archive
|
1291 |
+
zipf.write(file_path, os.path.relpath(file_path, directory))
|
1292 |
+
print(f"ZIP file created: {output_zip}")
|
|
|
1293 |
|
1294 |
def directory_exists(repo_id, directory, token):
|
1295 |
try:
|