Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -71,6 +71,10 @@ import base64
|
|
71 |
#for PDF form filling
|
72 |
from PyPDFForm import FormWrapper
|
73 |
|
|
|
|
|
|
|
|
|
74 |
#Variables Initialization
|
75 |
agent_executor = None
|
76 |
vector_store1 = None
|
@@ -1152,12 +1156,8 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1152 |
docstatus = f"Download the complete dataset <a href='https://redmindtechnologies.com/RedMindGPT/output.xlsx' download> here.</a>.There are total of {total_rows} rows."
|
1153 |
if total_rows < 4000:
|
1154 |
|
1155 |
-
# 1. Limit to first 10 rows
|
1156 |
|
1157 |
-
|
1158 |
-
# 2. Handle missing values
|
1159 |
-
#limited_data.fillna("N/A", inplace=True)
|
1160 |
-
# 3. Drop the original first column
|
1161 |
if len(df.columns) > 1:
|
1162 |
# Skipping the original first column
|
1163 |
limited_data = df.head(3)
|
@@ -1165,8 +1165,8 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1165 |
else:
|
1166 |
limited_data = df.head(20)
|
1167 |
limited_data_without_first_column = limited_data
|
1168 |
-
|
1169 |
-
#
|
1170 |
if isDataFrame :
|
1171 |
|
1172 |
limited_data_without_first_column.insert(0, 'SNo', range(1, len(limited_data_without_first_column) + 1))
|
@@ -1176,10 +1176,6 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1176 |
# 3. Save the full dataset to a downloadable file
|
1177 |
|
1178 |
|
1179 |
-
import os
|
1180 |
-
|
1181 |
-
# Get the current working directory
|
1182 |
-
current_folder = os.getcwd()
|
1183 |
|
1184 |
|
1185 |
file_path = "output_data.xlsx"
|
@@ -1187,8 +1183,8 @@ def handle_large_dataset(df, create_document,isDataFrame):
|
|
1187 |
df.to_excel(file_path, index=False)
|
1188 |
|
1189 |
|
1190 |
-
|
1191 |
-
|
1192 |
global user_name
|
1193 |
# Get today's date and current time
|
1194 |
now = datetime.now()
|
@@ -1228,9 +1224,7 @@ def create_file_HF(file_path,directory):
|
|
1228 |
|
1229 |
api = HfApi()
|
1230 |
|
1231 |
-
repo_id = "Redmind/NewageNXTGPT_Repo_trial"
|
1232 |
-
|
1233 |
-
|
1234 |
|
1235 |
|
1236 |
|
@@ -1240,7 +1234,7 @@ def create_file_HF(file_path,directory):
|
|
1240 |
directory = directory + "/" + file_path
|
1241 |
else:
|
1242 |
directory = directory + "/" + file_path
|
1243 |
-
|
1244 |
|
1245 |
#create_branch("Redmind/NewageNXTGPT_Repo_trial", repo_type="space", branch="test-branch")
|
1246 |
|
@@ -1268,11 +1262,7 @@ def create_pdf(cname,ename,account_number, directory):
|
|
1268 |
output.write(filled.read())
|
1269 |
create_file_HF(output_file_name, directory)
|
1270 |
|
1271 |
-
|
1272 |
-
file_output=f"static/{output_file_name}"
|
1273 |
-
from huggingface_hub import HfApi
|
1274 |
-
api = HfApi()
|
1275 |
-
#api.upload_file(path_or_fileobj=output_file_name, repo_id=repo_id, repo_type= "space", path_in_repo=file_output)
|
1276 |
return f"{output_file_name} is created successfully."
|
1277 |
|
1278 |
|
|
|
71 |
#for PDF form filling
|
72 |
from PyPDFForm import FormWrapper
|
73 |
|
74 |
+
import os
|
75 |
+
|
76 |
+
# Get the current working directory
|
77 |
+
current_folder = os.getcwd()
|
78 |
#Variables Initialization
|
79 |
agent_executor = None
|
80 |
vector_store1 = None
|
|
|
1156 |
docstatus = f"Download the complete dataset <a href='https://redmindtechnologies.com/RedMindGPT/output.xlsx' download> here.</a>.There are total of {total_rows} rows."
|
1157 |
if total_rows < 4000:
|
1158 |
|
|
|
1159 |
|
1160 |
+
# 1. Drop the original first column
|
|
|
|
|
|
|
1161 |
if len(df.columns) > 1:
|
1162 |
# Skipping the original first column
|
1163 |
limited_data = df.head(3)
|
|
|
1165 |
else:
|
1166 |
limited_data = df.head(20)
|
1167 |
limited_data_without_first_column = limited_data
|
1168 |
+
|
1169 |
+
# 2. Add SNo (serial number) as the first column, starting from 1
|
1170 |
if isDataFrame :
|
1171 |
|
1172 |
limited_data_without_first_column.insert(0, 'SNo', range(1, len(limited_data_without_first_column) + 1))
|
|
|
1176 |
# 3. Save the full dataset to a downloadable file
|
1177 |
|
1178 |
|
|
|
|
|
|
|
|
|
1179 |
|
1180 |
|
1181 |
file_path = "output_data.xlsx"
|
|
|
1183 |
df.to_excel(file_path, index=False)
|
1184 |
|
1185 |
|
1186 |
+
|
1187 |
+
|
1188 |
global user_name
|
1189 |
# Get today's date and current time
|
1190 |
now = datetime.now()
|
|
|
1224 |
|
1225 |
api = HfApi()
|
1226 |
|
1227 |
+
repo_id = "Redmind/NewageNXTGPT_Repo_trial"
|
|
|
|
|
1228 |
|
1229 |
|
1230 |
|
|
|
1234 |
directory = directory + "/" + file_path
|
1235 |
else:
|
1236 |
directory = directory + "/" + file_path
|
1237 |
+
|
1238 |
|
1239 |
#create_branch("Redmind/NewageNXTGPT_Repo_trial", repo_type="space", branch="test-branch")
|
1240 |
|
|
|
1262 |
output.write(filled.read())
|
1263 |
create_file_HF(output_file_name, directory)
|
1264 |
|
1265 |
+
|
|
|
|
|
|
|
|
|
1266 |
return f"{output_file_name} is created successfully."
|
1267 |
|
1268 |
|