Skip to content

Instantly share code, notes, and snippets.

@tomwolber
Created December 18, 2013 21:12
Show Gist options
  • Save tomwolber/8029917 to your computer and use it in GitHub Desktop.
Save tomwolber/8029917 to your computer and use it in GitHub Desktop.
import os
import gspread
import json
gpass = os.environ['GPASS']
gc = gspread.login('[email protected]', gpass)
sh = gc.open('irobot_FE_Translation_Final')
worksheet = sh.get_worksheet(0)
thekeys = worksheet.col_values(1)
q = input("Number of column to grab: ")
print '\n'
print '-'*80
print '\n'
data = worksheet.col_values(q)
out = ""
show_line_nums = False
z = 0
for idx,item in enumerate(thekeys):
z += 1
if z != idx+1:
print ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ERROR", z
if idx == 0:
pass
elif item == None:
pass
else:
if data[idx]:
if item.endswith('"",'):
t = "%s%s%s%s" % ( item.split('"",')[0],'"',data[idx],'",')
if show_line_nums: print idx+1,t
out += t
continue
else:
if(item.split(":")[1]):
if(item.split(":")[1].endswith('",')):
t = "%s%s%s%s" % ( item.split(':')[0],':"',data[idx],'",')
if show_line_nums: print idx+1,t
out += t
elif(item.split(":")[1].endswith('"')):
t = "%s%s%s%s" % ( item.split(':')[0],':"',data[idx],'"')
if show_line_nums: print idx+1,t
out += t
else:
t = item
if show_line_nums: print idx+1,t
out += t
t ='}'
out += t
if show_line_nums: print idx+2,t
parsed = json.loads(out)
print json.dumps(parsed, sort_keys=False, indent=2, ensure_ascii=False)
#print parsed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment