I have a json data as below and i have one uri to match in each fields. If match found then don't go for next iteration of [fields]. Concept is the users have clicked urls after searching. If user clicked the 3rd url then collect 1st, 2nd, 3rd data values. Dont go for 4th value.
If user clicked 5th url then collect 1st to 5th fields uri and exit that json object. Take a new json object and do same procedure.
[document]-> [fields1] -> [uri]
[document]-> [fields2] -> [uri]
[document]-> [fields3] -> [uri]
.....
.. till 20-30 times.
I have written below code, but the above logic is not working. Kindly help on this.
uri='http://abcd.com/123.html'
print(uri)
for index_srch_log,row_srch_log in df_search_log_mongo.iterrows():
RESPONSE = row_srch_log['RESPONSE']
json_response = json.loads(RESPONSE)
if 'documents' in json_response:
field_data=json_response['documents']
for row_resp_list in field_data:
print('uri:',row_resp_list['fields']['uri'])
match_found=False
for i in row_resp_list['fields']['uri']:
print('i',i)
if uri == i:
print('yes matched')
match_found=True
break
print('found')
else:
print('not matched')
match_found=False
if match_found==True:
break
Aucun commentaire:
Enregistrer un commentaire