-
Notifications
You must be signed in to change notification settings - Fork 0
/
csv_file_to_text2.py
executable file
·63 lines (53 loc) · 1.63 KB
/
csv_file_to_text2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
import tokenize
from collections import OrderedDict
import csv
import random
fname=sys.argv[1]
inf=open(fname,'r')
articles=OrderedDict()
with open(fname, 'rb') as csvfile:
csvreader=csv.reader(csvfile,delimiter=',')
next(csvreader)
for l in csvreader:
key=l[1];
if key not in articles.keys():
articles[key]=OrderedDict()
articles[key]=[l]
else:
articles[key].append(l)
from parse_jnl import read_journal_list_file
journal_name_map=read_journal_list_file('Assigned_Journals.txt')
wlines=""
for key,jname in random.sample(journal_name_map.items(),len(journal_name_map.keys())):
#print key,jname
#for key,value in random.sample(articles.items(),len(articles.keys())):
wlines+="\n################################################\n"
wlines+="PRESENTER: "+key+'\n'
wlines+="################################################\n"
wlines+="\n".join(jname)+"\n"
wlines+="______________________________________\n"
wlines+="\n"
try:
value=articles[key]
counter=1
for val in value:
wlines+="("+str(counter)+")"+"\n"
wlines+="JOURNAL: "+val[2]+'\n'
wlines+="TITLE: "+val[4]+'\n'
wlines+="AUTHORS: "+val[5]+'\n'
wlines+="VOLUME: "+val[3]+'\n'
wlines+="SUMMARY: \n"+'\t '+'\n\t '.join(val[7].split('\n'))+'\n'
wlines+="\nWEB LINK: "+val[8]+'\n'
wlines+="WHO SHOULD READ: "+val[9]+'\n'
wlines+="_______________________________________________________\n"
wlines+="\n"
counter+=1;
wlines+="\n\n"
except:
wlines+="Papers Not Uploaded "+'\n'
wlines+="______________________________________\n"
wlines+="\n\n\n"
outf=open('Journal_Club_papers.txt','w')
outf.writelines(wlines)
outf.close()