Skip to content

Instantly share code, notes, and snippets.

@cigrainger
Created February 24, 2014 12:49
Show Gist options
  • Select an option

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

Select an option

Save cigrainger/9187785 to your computer and use it in GitHub Desktop.
import sys
import re
f = open('~/Documents/spillovers/tech_proximity2/orbis_patents_titles.csv').read()
patents = {}
rows = f.split('\n')[1:]
numbers = [j.split(',')[0] for j in rows]
titles = [j.split(',')[1:] for j in rows]
for i in range(0,len(numbers)):
patents[numbers[i]] = titles[i]
for i in len(titles)
titles[i] = re.replace(',','',titles[i])
f = open('patenttitles.csv','w')
f.truncate()
f.write('numbers','titles')
for i in range(0,len(patents.keys())):
f.write('\n'+patents.keys()[i]+','+patents.values()[i])
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment