wrongmove/crawler/9_recalculate_regex_squaremeter.py

16 lines
535 B
Python
Raw Normal View History

# recalculate regex from sqm from already previously ocr'ed text
import json
from rec.floorplan import extract_total_sqm
from tqdm import tqdm
from data_access import Listing
for listing in tqdm(list(Listing.get_all_listings())):
with open(listing.path_floorplan_ocr_json()) as f:
floorplans = json.load(f)
for floorplan in floorplans:
2024-03-25 20:48:48 +00:00
floorplan["estimated_sqm"] = extract_total_sqm(floorplan["text"])
2024-03-25 20:48:48 +00:00
with open(listing.path_floorplan_ocr_json(), "w") as f:
floorplans = json.dump(floorplans, f)