Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
drgnfrts
GitHub Repository: drgnfrts/Singapore-Locations-NER
Path: blob/main/archive/unclean_locations_data/ria_cleaner.ipynb
744 views
Kernel: Python 3.8.12 ('spacyenv')

This piece is here because some idiot input estate name as building name for some buildings, which proceeded to screw with my code. I couldn't figure out a way to generate an exception for it in the main filter ipynb, so I decided to clean the data. At least I know how to modify and overwrite JSON files now.

import json import os with open('../data/singapore-postal-codes/buildings.json', 'r') as read_file: data = json.load(read_file)
for i in range(len(data)): if data[i]["SEARCHVAL"] == "SPRINGWOOD": data[i]["SEARCHVAL"] = data[i]["ADDRESS"]
os.remove('../data/singapore-postal-codes/buildings.json') with open('../data/singapore-postal-codes/buildings.json', 'w') as f: json.dump(data, f, indent=4)