Skip to content

Instantly share code, notes, and snippets.

@cigrainger
Created March 13, 2014 17:32
Show Gist options
  • Select an option

  • Save cigrainger/9533025 to your computer and use it in GitHub Desktop.

Select an option

Save cigrainger/9533025 to your computer and use it in GitHub Desktop.
f = open('C:\Users\graingec\spillovers\patentstitles.csv','r').read()
rows = f.split('\n')
titles = []
id = []
for i in rows:
if len(i.split('"')) == 9:
titles.append(i.split('"')[7])
id.append(i.split('"')[4])
for i in range(0,len(id)):
id[i] = id[i].replace("\\","")
appln = {}
for i in range(0,len(id)):
appln[id[i]] = titles[i]
z = open("C:\Users\graingec\spillovers\data\mrtitles.csv",'w')
z.truncate()
for i in range(0,len(appln.keys())):
z.write(appln.keys()[i]+'\t'+appln.values()[i]+'\n')
z.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment