skip to Main Content

Converting JSON/dict to flatten string with indicator tokens

Given an input like: {'example_id': 0, 'query': ' revent 80 cfm', 'query_id': 0, 'product_id': 'B000MOO21W', 'product_locale': 'us', 'esci_label': 'I', 'small_version': 0, 'large_version': 1, 'split': 'train', 'product_title': 'Panasonic FV-20VQ3 WhisperCeiling 190 CFM Ceiling Mounted Fan', 'product_description': None, 'product_bullet_point': 'WhisperCeiling fans feature…

VIEW QUESTION

Json – API request – TypeError: string indices must be integers

I develop a simple API request. Here is the code: import requests import json #Get data result = requests.get("https://pkip.riga.lv/documentregistration/divisionregister?district_id=516&division_id=2863") divisions = json.loads(result.content) info_list = [] for info in divisions: info_list.append(info["valid_from"]) print (info_list) div_list = list(dict.fromkeys(info_list)) #Sort div_list.sort() #Print for info…

VIEW QUESTION
Back To Top
Search