Redmind commited on
Commit
b53a294
·
verified ·
1 Parent(s): 81844dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
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
- zip_name = 'output_files.zip'
1214
- print(zip_name)
1215
- zip_files_in_folder(directory, zip_name)
1216
- create_file_HF(zip_name,directory, False)
 
 
 
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
- # Create a Zip file
1281
- #folder_path="./"
1282
- print(folder_path)
1283
- with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zipf:
1284
- # Walk through the folder
1285
- for root, dirs, files in os.walk(folder_path):
1286
  for file in files:
1287
- file_path = os.path.join(root, file)
1288
- # Add each file to the zip file
1289
- zipf.write(file_path, os.path.relpath(file_path, folder_path))
1290
-
1291
- print(f"Zip file '{zip_name}' created successfully!")
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: