Skip to content

Instantly share code, notes, and snippets.

@manishmore
Created August 11, 2020 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manishmore/20f72384234bcae5a1413828a3200f7c to your computer and use it in GitHub Desktop.
Save manishmore/20f72384234bcae5a1413828a3200f7c to your computer and use it in GitHub Desktop.
Search based on the user input from json file given.
import json
import datetime
import re
# Input the key value that you want to search
keyVal = input("Enter a key value: \n")
keyNum = input("Enter a number of days: \n")
with open('metadata.json') as json_file:
data = json.load(json_file)
for p, item in enumerate(data):
for Itemcount,iterator_var in enumerate(item):
if item[iterator_var] == keyVal:
print(item)
for value,valueItem in enumerate(item):
l = re.compile("T").split(item['creationTimestamp'])
valueDay = re.compile("-").split(l[0])
diffVal = valueDay[2]
#print(diffVal)
#print(valueItem)
pass
#print('test')
#print(item)
#print(p)
#print(iterator_var)
#print('Name: ' + p)
#print('Website: ' + p['website'])
#print('From: ' + p['from'])
#print('')
#print(keyNum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment