<jupyter_start><jupyter_text>Clan the district, cuisine, dish columns<jupyter_code>df = pd.read_csv('restaurant_clean.csv', index_col=0)
with open('all_restaurant.json', 'w') as f:
    json.dump({}, f)
re_dict={}
def ogcioparser_dict(address):
    data = {"q":address, "n":1} #n means only send 1 
    headers ={"Accept": "application/json"}
    api_url = "https://www.als.ogcio.gov.hk/lookup"
    res = requests.post(api_url, data=data, headers=headers, timeout=(5, 14))
    add = json.loads(res.text)
    add_dict = {}
    add_dict['Latitude'] = add['SuggestedAddress'][0]['Address']['PremisesAddress']['GeospatialInformation'][0]['Latitude']    
    add_dict['Longitude'] = add['SuggestedAddress'][0]['Address']['PremisesAddress']['GeospatialInformation'][0]['Longitude']
    add_dict['Easting'] = add['SuggestedAddress'][0]['Address']['PremisesAddress']['GeospatialInformation'][0]['Easting']
    add_dict['Northing'] = add['SuggestedAddress'][0]['Address']['PremisesAddress']['GeospatialInformation'][0]['Northing']
    return add_dict
addresses = df['address']
sleep_counter = 0
all_dict = {}
working_dict = {}
for i, a in enumerate(tqdm(addresses)):
    parse = ogcioparser_dict(a)
    all_dict[i] = parse
    working_dict[i] = parse
    sleep_counter +=1
    if sleep_counter % 500 == 0:
        sleep(randint(5,10))

        with open('all_restaurant.json') as f:
            file = json.load(f)

        file.update(working_dict)

        with open('all_restaurant.json', 'w') as f:
            json.dump(file, f)
            
        working_dict = {}
df_parse = pd.DataFrame.from_dict(all_dict, orient='index')
df_parse.to_csv('parse.csv')
!ipython nbconvert --to=python openrice_allrestaurant_2.ipynb<jupyter_output>[TerminalIPythonApp] WARNING | Subcommand `ipython nbconvert` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter nbconvert` in the future
[NbConvertApp] Converting notebook openrice_allrestaurant_2.ipynb to python
[NbConvertApp] Writing 1854 bytes to openrice_allrestaurant_2.py
{'fraction_non_alphanumeric': 0.15050651230101303, 'fraction_numerical': 0.01447178002894356, 'mean_word_length': 5.011594202898551, 'pattern_counts': {'":': 3, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '201447', 'license': 'MIT', 'n_tokens_mistral': 731, 'n_tokens_neox': 695, 'n_words': 134, 'path': 'restaurant/openrice_parse_ogcio.ipynb', 'repo_name': 'youonf/location_intelligence', 'size': '2073'}