Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1155,7 +1155,7 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1155 |
print(f"Total rows: {total_rows}")
|
1156 |
|
1157 |
#docstatus = f"Download the complete dataset <a href='https://huggingface.co/spaces/Redmind/NewageNXTGPT/blob/main/assets/output.xlsx' download> here.</a>.There are total of {total_rows} rows."
|
1158 |
-
|
1159 |
if total_rows < 4000:
|
1160 |
|
1161 |
|
@@ -1196,6 +1196,8 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1196 |
print(formatted_date_time)
|
1197 |
directory = user_name + "/" + formatted_date_time
|
1198 |
create_file_HF(file_path, directory,False)
|
|
|
|
|
1199 |
print("File created in the home path")
|
1200 |
|
1201 |
#save_file_to_hostinger('output_data.xlsx')
|
@@ -1217,7 +1219,9 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1217 |
print(zip_file_name)
|
1218 |
zip_files_in_folder(directory, zip_file_name)
|
1219 |
create_file_HF(zip_file_name,directory, False)
|
1220 |
-
|
|
|
|
|
1221 |
print(sample_table)
|
1222 |
# 5. Return the summary and downloadable link
|
1223 |
#return f"""
|
@@ -1279,7 +1283,7 @@ def create_pdf(cname,ename,account_number, directory):
|
|
1279 |
|
1280 |
return f"{output_file_name} is created successfully."
|
1281 |
|
1282 |
-
def zip_files_in_folder(
|
1283 |
# Initialize the ZIP file
|
1284 |
directory = "./"
|
1285 |
with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
@@ -1290,7 +1294,7 @@ def zip_files_in_folder(directory, output_zip):
|
|
1290 |
if file.endswith(".pdf") and os.path.isfile(file_path):
|
1291 |
# Add file to the ZIP archive
|
1292 |
zipf.write(file_path, file) # Save with its filename in the ZIP
|
1293 |
-
print(f"ZIP file created: {output_zip}, {
|
1294 |
|
1295 |
def directory_exists(repo_id, directory, token):
|
1296 |
try:
|
@@ -1306,11 +1310,11 @@ def directory_exists(repo_id, directory, token):
|
|
1306 |
print(f"Error checking directory existence: {e}")
|
1307 |
return False
|
1308 |
|
1309 |
-
def get_download_link(file_path):
|
1310 |
# Hugging Face Spaces uses this URL format for repository-hosted files
|
1311 |
-
base_url = "https://huggingface.co/spaces/<your-space-id>/blob/
|
1312 |
# Replace <your-space-id> with your actual Space name
|
1313 |
-
return f"{base_url}/{file_path}"
|
1314 |
|
1315 |
css = """
|
1316 |
|
|
|
1155 |
print(f"Total rows: {total_rows}")
|
1156 |
|
1157 |
#docstatus = f"Download the complete dataset <a href='https://huggingface.co/spaces/Redmind/NewageNXTGPT/blob/main/assets/output.xlsx' download> here.</a>.There are total of {total_rows} rows."
|
1158 |
+
|
1159 |
if total_rows < 4000:
|
1160 |
|
1161 |
|
|
|
1196 |
print(formatted_date_time)
|
1197 |
directory = user_name + "/" + formatted_date_time
|
1198 |
create_file_HF(file_path, directory,False)
|
1199 |
+
dataset_link = get_download_link(directory,file_path)
|
1200 |
+
docstatus = f"Download the complete dataset <a href={dataset_link} download> here.</a>.There are total of {total_rows} rows."
|
1201 |
print("File created in the home path")
|
1202 |
|
1203 |
#save_file_to_hostinger('output_data.xlsx')
|
|
|
1219 |
print(zip_file_name)
|
1220 |
zip_files_in_folder(directory, zip_file_name)
|
1221 |
create_file_HF(zip_file_name,directory, False)
|
1222 |
+
link = get_download_link(directory,zip_file_name)
|
1223 |
+
print(f"downloadable link: {link}")
|
1224 |
+
docstatus = f"Please download the complete dataset here: <a href={link} download>Download</a>. {total_rows} documents are created successfully."
|
1225 |
print(sample_table)
|
1226 |
# 5. Return the summary and downloadable link
|
1227 |
#return f"""
|
|
|
1283 |
|
1284 |
return f"{output_file_name} is created successfully."
|
1285 |
|
1286 |
+
def zip_files_in_folder(directory_output, output_zip):
|
1287 |
# Initialize the ZIP file
|
1288 |
directory = "./"
|
1289 |
with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
|
1294 |
if file.endswith(".pdf") and os.path.isfile(file_path):
|
1295 |
# Add file to the ZIP archive
|
1296 |
zipf.write(file_path, file) # Save with its filename in the ZIP
|
1297 |
+
print(f"ZIP file created: {output_zip}, {output_zip}, {directory_output}")
|
1298 |
|
1299 |
def directory_exists(repo_id, directory, token):
|
1300 |
try:
|
|
|
1310 |
print(f"Error checking directory existence: {e}")
|
1311 |
return False
|
1312 |
|
1313 |
+
def get_download_link(file_path,file_name):
|
1314 |
# Hugging Face Spaces uses this URL format for repository-hosted files
|
1315 |
+
base_url = "https://huggingface.co/spaces/<your-space-id>/blob/test-branch"
|
1316 |
# Replace <your-space-id> with your actual Space name
|
1317 |
+
return f"{base_url}/{file_path}/{file_name}"
|
1318 |
|
1319 |
css = """
|
1320 |
|