Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1184,7 +1184,15 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1184 |
|
1185 |
#file_path = "output_data.xlsx"
|
1186 |
#download_url = repo.get_download_url(file_path)
|
1187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1188 |
print("File created in the home path")
|
1189 |
|
1190 |
#save_file_to_hostinger('output_data.xlsx')
|
@@ -1197,7 +1205,7 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1197 |
#Logic to generate pdfs with employee name and account number
|
1198 |
for index, row in df.iterrows():
|
1199 |
# Create a PDF for each row
|
1200 |
-
create_pdf(row['COMPANY'], row['EMPLOYEE NAME'], row['ACCOUNT NUMBER'])
|
1201 |
create_document = False
|
1202 |
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."
|
1203 |
print(sample_table)
|
@@ -1211,20 +1219,14 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1211 |
else:
|
1212 |
return "Your query returns a large dataset which is not supported in the current version. Please try a different query."
|
1213 |
|
1214 |
-
def create_file_HF(file_path):
|
1215 |
from huggingface_hub import create_branch, create_tag
|
1216 |
from huggingface_hub import login
|
1217 |
from huggingface_hub import HfApi
|
1218 |
api = HfApi()
|
1219 |
-
|
1220 |
repo_id = "Redmind/NewageNXTGPT_Repo_trial"
|
1221 |
-
# Get today's date and current time
|
1222 |
-
now = datetime.now()
|
1223 |
|
1224 |
-
# Format the date and time as 'YYYY-MM-DD HH:MM'
|
1225 |
-
formatted_date_time = now.strftime("%Y-%m-%d %H:%M")
|
1226 |
-
print(formatted_date_time)
|
1227 |
-
directory = user_name + "/" + formatted_date_time
|
1228 |
|
1229 |
|
1230 |
|
@@ -1243,9 +1245,10 @@ def create_file_HF(file_path):
|
|
1243 |
|
1244 |
|
1245 |
api.upload_file(path_or_fileobj=file_path, repo_id="Redmind/NewageNXTGPT_Repo_trial",revision = "test-branch", repo_type= "space", path_in_repo=directory)
|
|
|
1246 |
|
1247 |
|
1248 |
-
def create_pdf(cname,ename,account_number):
|
1249 |
|
1250 |
filled = FormWrapper("LOA_Sample_new.pdf").fill(
|
1251 |
{
|
@@ -1257,8 +1260,10 @@ def create_pdf(cname,ename,account_number):
|
|
1257 |
},
|
1258 |
)
|
1259 |
output_file_name = f"documents\\{ename}_{cname}.pdf"
|
|
|
1260 |
with open(output_file_name, "wb+") as output:
|
1261 |
output.write(filled.read())
|
|
|
1262 |
|
1263 |
repo_id = "Redmind/NewageNXTGPT"
|
1264 |
file_output=f"static/{output_file_name}"
|
|
|
1184 |
|
1185 |
#file_path = "output_data.xlsx"
|
1186 |
#download_url = repo.get_download_url(file_path)
|
1187 |
+
global user_name
|
1188 |
+
# Get today's date and current time
|
1189 |
+
now = datetime.now()
|
1190 |
+
|
1191 |
+
# Format the date and time as 'YYYY-MM-DD HH:MM'
|
1192 |
+
formatted_date_time = now.strftime("%Y-%m-%d %H:%M")
|
1193 |
+
print(formatted_date_time)
|
1194 |
+
directory = user_name + "/" + formatted_date_time
|
1195 |
+
create_file_HF(file_path, directory)
|
1196 |
print("File created in the home path")
|
1197 |
|
1198 |
#save_file_to_hostinger('output_data.xlsx')
|
|
|
1205 |
#Logic to generate pdfs with employee name and account number
|
1206 |
for index, row in df.iterrows():
|
1207 |
# Create a PDF for each row
|
1208 |
+
create_pdf(row['COMPANY'], row['EMPLOYEE NAME'], row['ACCOUNT NUMBER'],directory)
|
1209 |
create_document = False
|
1210 |
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."
|
1211 |
print(sample_table)
|
|
|
1219 |
else:
|
1220 |
return "Your query returns a large dataset which is not supported in the current version. Please try a different query."
|
1221 |
|
1222 |
+
def create_file_HF(file_path,directory):
|
1223 |
from huggingface_hub import create_branch, create_tag
|
1224 |
from huggingface_hub import login
|
1225 |
from huggingface_hub import HfApi
|
1226 |
api = HfApi()
|
1227 |
+
|
1228 |
repo_id = "Redmind/NewageNXTGPT_Repo_trial"
|
|
|
|
|
1229 |
|
|
|
|
|
|
|
|
|
1230 |
|
1231 |
|
1232 |
|
|
|
1245 |
|
1246 |
|
1247 |
api.upload_file(path_or_fileobj=file_path, repo_id="Redmind/NewageNXTGPT_Repo_trial",revision = "test-branch", repo_type= "space", path_in_repo=directory)
|
1248 |
+
reuturn directory
|
1249 |
|
1250 |
|
1251 |
+
def create_pdf(cname,ename,account_number, directory):
|
1252 |
|
1253 |
filled = FormWrapper("LOA_Sample_new.pdf").fill(
|
1254 |
{
|
|
|
1260 |
},
|
1261 |
)
|
1262 |
output_file_name = f"documents\\{ename}_{cname}.pdf"
|
1263 |
+
|
1264 |
with open(output_file_name, "wb+") as output:
|
1265 |
output.write(filled.read())
|
1266 |
+
create_file_HF(output_file_name, directory)
|
1267 |
|
1268 |
repo_id = "Redmind/NewageNXTGPT"
|
1269 |
file_output=f"static/{output_file_name}"
|