Skip to content

Instantly share code, notes, and snippets.

@jhejderup
Last active March 9, 2020 16:03
Show Gist options
  • Save jhejderup/fae77220fe4eef37591c3ebe78cd6dbf to your computer and use it in GitHub Desktop.
Save jhejderup/fae77220fe4eef37591c3ebe78cd6dbf to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
# -*- coding: utf-8 -*-
""" Convert EasyChair data into ACM data for eRights generation
Run: python3 easychair2acm.py <submitted_papers.csv> <authors.csv> <accepted_papers.csv>
"""
import sys
assert len(sys.argv) == 4
_papertype_mappings = {}
_papertype_mappings["experience-full"] = "Full Paper"
_papertype_mappings["experience-short"] = "Short Paper"
_papertype_mappings["research-full"] = "Full Paper"
_papertype_mappings["research-short"] = "Short Paper"
_papertype_mappings["tool-full"] = "Full Paper"
_papertype_mappings["tool-short"] = "Short Paper"
_id_papertype_mappings = {}
with open (sys.argv[1], mode='r', encoding='utf-8-sig') as submitted_file:
for line in submitted_file:
# PAPER ID;PAPER TITLE;PAPER-TYPE
record = line.rstrip().split(";")
# PAPER ID -> PAPER-TYPE
_id_papertype_mappings[record[0].strip()] = record[2].strip()
# id -> [Author1, Author2,..., AuthorN] (should be in order)
_id_authornames_mappings = {}
# id -> [email1, email2,..., emailN] (should be in order)
_id_authoremails_mappings = {}
class AuthorAffiliation:
def __init__(self,first_name,last_name,affiliation):
self.first_name = first_name
self.last_name = last_name
self.affiliation = affiliation
def __str__(self):
return '{} {}:{}'.format(self.first_name, self.last_name, self.affiliation)
def __repr__(self):
return '{} {}:{}'.format(self.first_name, self.last_name, self.affiliation)
# WARNING: This assumes the entries in the file are ordered (lead author first)
with open (sys.argv[2], mode='r', encoding='utf-8-sig') as authors_file:
for line in authors_file:
# PAPER ID;PAPER TITLE;FIRSTNAME;LASTNAME;EMAIL;AFFILIATION;COUNTRY_CODE
record = line.rstrip().split(";")
id = record[0].strip()
first_name = record[2].strip()
last_name = record[3].strip()
email = record[4].strip()
aff = record[5].strip()
if id in _id_authoremails_mappings:
_id_authornames_mappings[id].append(AuthorAffiliation(first_name,last_name,aff))
else:
authors = list()
authors.append(AuthorAffiliation(first_name,last_name,aff))
_id_authornames_mappings[id] = authors
if id in _id_authoremails_mappings:
_id_authoremails_mappings[id].append(email)
else:
emails = list()
emails.append(email)
_id_authoremails_mappings[id] = emails
def getACMType(paper_id):
type = _id_papertype_mappings[paper_id]
if type in _papertype_mappings:
return _papertype_mappings[type]
else:
return "!!!MISSING!!!"
acmcsv = open("acm-eRights.csv", "w")
with open (sys.argv[3], mode='r', encoding='utf-8-sig') as accepted_file:
for line in accepted_file:
# PAPER ID;PAPER TITLE;STATUS
record = line.rstrip().split(";")
id = record[0].strip()
title = record[1].strip()
assert record[2] == "ACCEPT"
authors = [str(author) for author in _id_authornames_mappings[id]]
emails = [ '{}'.format(email) for email in _id_authoremails_mappings[id]]
lead_email = emails.pop(0)
assert len(emails) + 1 == len(authors)
entry = '"{}","{}","{}","{}","{}"\n'.format(
getACMType(id),
title,
';'.join(authors),
lead_email,
';'.join(emails)
)
acmcsv.write(entry)
acmcsv.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment