from datetime import datetime
import json
import argparse
import csv


def main():

    parser = argparse.ArgumentParser(description='Make a citation network from the cited_by json')
    parser.add_argument('-i', help='Cited_by file')
    parser.add_argument('-o', help='TSV output file')
    args = parser.parse_args()

    with open(args.i, 'r') as i:
        with open(args.o, 'w') as o:
            output = csv.writer(o, delimiter = '\t')
            output.writerow(['to','from', 'date'])
            for line in i:
                line = json.loads(line)
                output.writerow([line['parent_eid'], line['eid'], line['prism:coverDate']])


if __name__ == '__main__':
    main()

