Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,15 +63,23 @@ def compute_title(metadata):
|
|
63 |
# Load CRS lookup CSV and define a lookup function.
|
64 |
crs_lookup = pd.read_csv("docStore/crs5_codes.csv") # Assumes columns: "code" and "new_crs_value"
|
65 |
def lookup_crs_value(crs_key):
|
66 |
-
|
|
|
|
|
|
|
67 |
if not row.empty:
|
68 |
-
#
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
return ""
|
74 |
|
|
|
75 |
###########################################
|
76 |
# RAG Answer function (Change 1 & 2 & 3)
|
77 |
###########################################
|
|
|
63 |
# Load CRS lookup CSV and define a lookup function.
|
64 |
crs_lookup = pd.read_csv("docStore/crs5_codes.csv") # Assumes columns: "code" and "new_crs_value"
|
65 |
def lookup_crs_value(crs_key):
|
66 |
+
# Ensure the input is a string and clean it.
|
67 |
+
key_clean = re.sub(r'\.0$', '', str(crs_key).strip())
|
68 |
+
# Compare against the CSV codes as strings.
|
69 |
+
row = crs_lookup[crs_lookup["code"].astype(str) == key_clean]
|
70 |
if not row.empty:
|
71 |
+
# If a column named "new_crs_value" exists, use it.
|
72 |
+
if "new_crs_value" in row.columns:
|
73 |
+
try:
|
74 |
+
return re.sub(r'\.0$', '', str(int(float(row.iloc[0]["new_crs_value"]))))
|
75 |
+
except Exception:
|
76 |
+
return re.sub(r'\.0$', '', str(row.iloc[0]["new_crs_value"]))
|
77 |
+
else:
|
78 |
+
# Otherwise, use the "name" column as the lookup value.
|
79 |
+
return re.sub(r'\.0$', '', str(row.iloc[0]["name"]).strip())
|
80 |
return ""
|
81 |
|
82 |
+
|
83 |
###########################################
|
84 |
# RAG Answer function (Change 1 & 2 & 3)
|
85 |
###########################################
|