Skip to content

Commit

Permalink
Extended to handle csrankings-[a-z].
Browse files Browse the repository at this point in the history
  • Loading branch information
emeryberger committed Jun 18, 2021
1 parent 900a066 commit 8e1b224
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions util/split-csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import sys
import operator
import string

def csv2dict_str_str(fname):
"""Takes a CSV file and returns a dictionary of pairs."""
Expand All @@ -17,14 +18,14 @@ def csv2dict_str_str(fname):
d = {unicode(rows[0].strip(), 'utf-8'): unicode(rows[1].strip(), 'utf-8') for rows in rdr}
return d

# Merge all 'csrankings-[0-9].csv' into 'csrankings.csv'.
# Merge all 'csrankings-*.csv' into 'csrankings.csv'.
with open('csrankings.csv', mode='w') as outfile:
fieldnames = ["name","affiliation","homepage","scholarid"]
writer = csv.DictWriter(outfile, fieldnames)
writer.writeheader()
for i in range(10):
for i in list(string.ascii_lowercase + string.digits):
try:
fname = "csrankings-" + str(i) + ".csv"
fname = "csrankings-" + i + ".csv"
with open(fname, mode='r') as infile:
reader = csv.DictReader(infile)
for row in reader:
Expand Down

0 comments on commit 8e1b224

Please sign in to comment.