We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1277864 commit bee4c49Copy full SHA for bee4c49
1 file changed
app/schemas/base.py
@@ -1,3 +1,4 @@
1
+import re
2
from datetime import datetime
3
from typing import Optional
4
@@ -56,7 +57,16 @@ def parse_str_to_date(cls, v: str):
56
57
def parse_str_to_int(cls, v: str) -> Optional[int]:
58
if not v or not any(char.isdigit() for char in v):
59
return None
- value_str = v.lower().replace("€", "").replace("+", "").replace("'", "").strip()
60
+
61
+ # Clean up HTML tags if present
62
+ if "<" in str(v):
63
+ matches = re.findall(r"€([\d,.]+[kmb]?)", v.lower())
64
+ if not matches:
65
+ return None
66
+ value_str = matches[0]
67
+ else:
68
+ value_str = v.lower().replace("€", "").replace("+", "").replace("'", "").strip()
69
70
if "k" in value_str:
71
return int(float(value_str.replace("k", "")) * 1_000)
72
elif "m" in value_str:
0 commit comments