Skip to content

Instantly share code, notes, and snippets.

@arcolife
Forked from anonymous/file1.py
Created April 8, 2014 02:18
Show Gist options
  • Save arcolife/10083501 to your computer and use it in GitHub Desktop.
Save arcolife/10083501 to your computer and use it in GitHub Desktop.
import json
data = json.loads(open('_User.json','rb').read())
data
data['results'][0]
data['results'][23]
name = 'fc336b02-47e5-4a11-ba38-59e60da3dfe7-yusuf done.png"
name = 'fc336b02-47e5-4a11-ba38-59e60da3dfe7-yusuf done.png'
name.split()
'%20'.join(name.split())
data['results'][0]
data['results'][1]
data['results'][12]
data['results'][13]
data['results'][233]
data['results'][33]
data['results'][33]
data['results'][34]
data['results'][35]
data_p = json.loads(open('PortfolioPhoto.json','rb').read())
data_p
data_p.keys()
data_p['results'][35]
data['results'][35]
data_p
data_p[0]
data_p['results'][35]
data['results'][35]
for k in data['results']:
try:
k['headshot']['file']['url'] = u'/static/pics/' + k['headshot']['file']['name']
except:
pass
try:
if k['headshot']['photographer']['url']:
k['headshot']['photographer']['url'] = u'/static/pics/' + k['headshot']['photographer']['name']
except:
pass
try:
k['background']['file']['url'] = u'/static/pics/' + k['background']['file']['name']
except:
pass
k
for k in xrange(len(data['results'])):
try:
data['results'][k]['headshot']['file']['url'] = u'/static/pics/' + '%20'.join(data['results'][k]['headshot']['file']['name'])
except:
pass
try:
if data['results'][k]['headshot']['photographer']['url']:
data['results'][k]['headshot']['photographer']['url'] = u'/static/pics/' + '%20'.join(data['results'][k]['headshot']['photographer']['name'])
except:
pass
try:
data['results'][k]['background']['file']['url'] = u'/static/pics/' + '%20'.join(data['results'][k]['background']['file']['name'])
except:
pass
data
for k in xrange(len(data['results'])):
try:
data['results'][k]['headshot']['file']['url'] = u'/static/pics/' + '%20'.join(data['results'][k]['headshot']['file']['name'].split())
except:
pass
try:
if data['results'][k]['headshot']['photographer']['url']:
data['results'][k]['headshot']['photographer']['url'] = u'/static/pics/' + '%20'.join(data['results'][k]['headshot']['photographer']['name'].split())
except:
pass
try:
data['results'][k]['background']['file']['url'] = u'/static/pics/' + '%20'.join(data['results'][k]['background']['file']['name'].split())
except:
pass
data
data
data = json.dumps(data)
data
f = open('_User_new.json','wb')
f.write(data)
f.close()
data_p
data_p[0]
data_p['results'][35]
for k in xrange(len(data_p['results'])):
try:
data_p['results'][k]['file']['url'] = u'/static/pics/' + '%20'.join(data_p['results'][k]['file']['name'].split())
except:
pass
data_p
f = open('PortfolioPhoto_new.json','wb')
json.dump(data_p)
json.dumps(data_p)
f.write(json.dumps(data_p))
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment