-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcsvtojson.py
44 lines (38 loc) · 1.35 KB
/
csvtojson.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
import json
import csv
CSVFILE="/tmp/ranking.csv"
def main():
# load venues abbreviation data
data=[]
with open(CSVFILE) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
score = row[0]
cnpq = row[1]
name = row[2]
numA = row[3]
numB = row[4]
numC = row[5]
inst = row[6]
areas = row[7]
numConferencePapers = row[8]
numJournalPapers = row[9]
data.append(
{"name": name.strip(),
"institution": inst.strip(),
"area": areas.strip(),
"bolsa-cnpq": cnpq.strip(),
"num-csindexbr-papers": int(numA)+int(numB)+int(numC),
"num-csindexbr-confs": numConferencePapers,
"num-csindexbr-journals": numJournalPapers,
"num-tier-one": int(numA),
"num-tier-two": int(numB),
"num-tier-three": int(numC),
"csindexbr-score": float(score),
"papers": []
}
)
json_data = json.dumps({"data": data}, indent=4, separators=(',', ': '))
print(json_data)
if __name__ == "__main__":
main()