Skip to content

Instantly share code, notes, and snippets.

@arcolife
Forked from anonymous/file1.py
Created April 6, 2014 12:41
Show Gist options
  • Save arcolife/10005486 to your computer and use it in GitHub Desktop.
Save arcolife/10005486 to your computer and use it in GitHub Desktop.
import json
data = json.loads('_User.json','rb')
data = json.load('_User.json','rb')
data = json.load(open('_User.json','rb').read())
data = json.loads(open('_User.json','rb').read())
data
ls
data['results'].keys()
data['results']
data['results'][0]
data['results'][0].keys()
fields = []
mapping = open('mapping.json','rb').read()
mapping
mapping = json.loads(mapping)
mapping
mapping.keys()
mapping['users'].keys()
mapping['users']['properties'].keys()
map_keys = mapping['users']['properties'].keys()
map_keys
fields.extend(map_keys)
fields
mapping['users']['properties'].keys()
mapping['users']['properties']
mapping['users']['properties']['resume']
mapping['users']['properties']['resume'].keys()
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']
mapping['users']['properties']['resume']
type(mapping['users']['properties']['resume'])
keys
map_keys
for key in map_keys:
if type(mapping['users']['properties']) == dict:
print key
mapping['users']['properties']['resume']
mapping['users']['properties']['firstName']
mapping['users']['properties']['albums']
mapping['users']['properties']['keywords']
mapping['users']['properties']['email']
mapping['users']['properties']['settings']
for key in map_keys:
if type(mapping['users']['properties'][key]) == dict:
print key
mapping['users']['properties'][key]
key
for key in map_keys:
try:
print mapping['users']['properties'][key]['properties']
except:
continue
from pprint import pprint
for key in map_keys:
try:
pprint mapping['users']['properties'][key]['properties']
except:
continue
for key in map_keys:
try:
pprint mapping['users']['properties'][key]['properties']
except:
continue
for key in map_keys:
try:
pprint(mapping['users']['properties'][key]['properties']
except:
continue)
for key in map_keys:
try:
pprint(mapping['users']['properties'][key]['properties'])
except:
continue
for key in map_keys:
try:
pprint(mapping['users']['properties'][key]['properties'])
except:
continue
for key in map_keys:
try:
mapping['users']['properties'][key]['properties']
print key
except:
continue
for key in map_keys:
try:
mapping['users']['properties'][key]['properties']
print key
except:
continue
fields
map_keys
fields = []
for key in map_keys:
try:
mapping['users']['properties'][key]['properties']
fields.append(key)
except:
continue
fields
mapping['users']['properties'][fields[0]]
mapping['users']['properties'][fields[1]]
mapping['users']['properties'][fields[2]]
mapping['users']['properties'][fields[3]]
mapping['users']['properties'][fields[4]]
mapping['users']['properties'][fields[5]]
fields
mapping['users']['properties'][fields[6]]
for key in fields:
mapping['users']['properties'][key].keys()
for key in fields:
print mapping['users']['properties'][key].keys()
for key in fields:
print mapping['users']['properties'][key]['properties'].keys()
for key in fields:
print mapping['users']['properties'][key]['properties'].keys()
for key in fields:
print key, ":", mapping['users']['properties'][key]['properties'].keys()
list(set(map_keys) - set(fields))
mapping['users']['properties'][fields[-2]]
list(set(map_keys) - set(fields))
for key in fields:
print key, ":", mapping['users']['properties'][key]['properties'].keys()
mapping
mapping['users']['properties']['resume']
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']['resume']['properties'][u'gender'] = {u'type': u'string'}
mapping['users']['properties']['resume']['properties']
for key in fields:
print key, ":", mapping['users']['properties'][key]['properties'].keys()
list(set(map_keys) - set(fields))
set1 = list(set(map_keys) - set(fields))
for key in fields:
print key, ":", mapping['users']['properties'][key]['properties'].keys()
set2.append({ key : mapping['users']['properties'][key]['properties'].keys())
set2
set2 = []
for key in fields:
print key, ":", mapping['users']['properties'][key]['properties'].keys()
set2.append({ key : mapping['users']['properties'][key]['properties'].keys()})
set2
set2[0]
set2[1]
set2[0]
set2
set1
set2
mapping
set1
set2
fields
k = 'Exhaustive List'
k = u'Exhaustive List'
k
mapping['users']['properties']['resume']['properties']
mapping
set1
set2
mapping['users']['properties']['resume']['properties'][u'dob'] = {u'format': u'dateOptionalTime', u'type': u'date' }
mapping
set1
set2
mapping
set1
mapping['users']['properties']['resume']['properties'][u'vital'] = {u'properties': { u'chest' : {u'type': u'number'}}, u'waist' : {u'type': u'number'}}, u'hips' : {u'type': u'number'}}, u'bust' : {u'type': u'number'}}, 'biceps' : {u'type': u'number'}}}}
mapping['users']['properties']['resume']['properties'][u'vital'] = {u'properties': { u'chest' : {u'type': u'number'}, u'waist' : {u'type': u'number'}, u'hips' : {u'type': u'number'}, u'bust' : {u'type': u'number'}, 'biceps' : {u'type': u'number'}}}
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']['resume']['properties']['vital']
mapping['users']['properties']['resume']['properties']['vital']['properties']]
mapping['users']['properties']['resume']['properties']['vital']['properties']
mapping['users']['properties']['resume']['properties']['vital']['properties'].keys()
mapping['users']['properties']['resume']['properties']['vital']
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']
set1
set2
mapping['users']['properties']['resume']['properties'][u'weight'] = {u'type': u'number'}
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']
mapping
mapping['users']['properties']['contact']
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['contact']['properties']['number'] = {u'properties' : { u'phone' : {u'type' : u'number' }, u'country' : {u'type': u'number'}}}
mapping['users']['properties']['contact']
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['contact']['properties']['number']
mapping['users']['properties']['contact']['properties']['number'].keys()
mapping['users']['properties']['contact']['properties']['number']['properties'].keys()
mapping['users']['properties']
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['contact']['properties']['email'] = {u'type' : u'string'}
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['contact']['properties']
mapping['users']['properties']['contact']['properties']
sey1
set1
set2
mapping['users']['properties']['contact']['properties']
set1
set1
set2
mapping['users']['properties']['current_location'] = {u'type' : u'string'}
mapping['users']['properties']
mapping['users']['properties']
mapping['users']['properties'].keys()
mapping['users']['properties']['contact']['properties']
mapping['users']['properties'][u'current_location'] = {u'type' : u'string'}
mapping['users']['properties'][u'current_location']
mapping['users']['properties']
mapping['users']['properties'].keys()
a = {2:3}
a.popitem(2)
a.popitem()
a = { 'a':2, 'b':3}
a.popitem()
a
a = { 'a':2, 'b':3}
a.pop()
a.pop('a')
a = { 'a':2, 'b':3}
a.pop('b')
a
mapping.pop('current_location')
mapping['users']['properties'].pop('current_location')
mapping['users']['properties'][u'current_location'] = {u'type' : u'string'}
mapping['users']['properties'].keys()
mapping['users']['properties']['resume']['properties']
mapping['users']['properties']['resume']['properties'].keys()
mapping['users']['properties']['resume']['properties'][u'origin'] = {u'type': u'string'}
mapping['users']['properties']['resume']['properties'].keys()
mapping['users']['properties']
mapping['users']['properties'].keys()
mapping['users']['properties']['resume']['properties'].keys()
mapping['users']['properties']['resume']['properties'][u'languages'] = {u'type': u'string'}
mapping['users']['properties']['resume']['properties'].keys()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment