-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem-tracker.py
93 lines (74 loc) · 3.09 KB
/
problem-tracker.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 29 15:59:00 2019
@author: davidnelson
"""
import csv
import pandas as pd
def alpha_annotation_maker(fl, pid, ref):
if fl.startswith(('A', 'B', 'C', 'D')):
return f"<a href='/digital-beehive/alpha1/{pid}/'>{ref}</a>"
elif fl.startswith(('E', 'F', 'G', 'H')):
return f"<a href='/digital-beehive/alpha2/{pid}/'>{ref}</a>"
elif fl.startswith(('I', 'K', 'L', 'M', 'N')):
return f"<a href='/digital-beehive/alpha3/{pid}/'>{ref}</a>"
elif fl.startswith(('O', 'P', 'Q', 'R', 'S')):
return f"<a href='/digital-beehive/alpha4/{pid}/'>{ref}</a>"
else:
return f"<a href='/digital-beehive/alpha5/{pid}/'>{ref}</a>"
def index_annotation_maker(fl, pid, ref):
if fl.startswith(('A', 'B', 'C', 'D')):
return f"<a href='/digital-beehive/index1/{pid}/'>{ref}</a>"
elif fl.startswith(('E', 'F', 'G', 'H')):
return f"<a href='/digital-beehive/index2/{pid}/'>{ref}</a>"
elif fl.startswith(('I', 'K', 'L', 'M', 'N')):
return f"<a href='/digital-beehive/index3/{pid}/'>{ref}</a>"
elif fl.startswith(('O', 'P', 'Q', 'R', 'S')):
return f"<a href='/digital-beehive/index4/{pid}/'>{ref}</a>"
else:
return f"<a href='/digital-beehive/index5/{pid}/'>{ref}</a>"
def num_annotation_maker(entry, pid, ref):
if int(entry) <= 250:
return f"<a href='/digital-beehive/num1/{pid}/'>{ref}</a>"
elif int(entry) > 250:
return f"<a href='/digital-beehive/num2/{pid}/'>{ref}</a>"
with open('beehive-data-for-wax.csv', 'r') as ip:
bh_data = csv.DictReader(ip, delimiter=',')
ids = {}
for row in bh_data:
ids.update({row['item']: row['pid']})
with open('alpha-issues.csv', 'r') as f:
alpha_issues = pd.read_csv(f)
for row in alpha_issues.index:
item = alpha_issues.loc[row, 'item']
entry = alpha_issues.loc[row, 'entry']
first_letter = alpha_issues.loc[row, 'first_letter']
pid = ids[item]
link = alpha_annotation_maker(first_letter, pid, entry)
alpha_issues.loc[row, 'reference_link'] = link
new_csv = alpha_issues.to_csv('alpha-issues.csv', index=False)
print('Alphabetical section done.')
with open('index-issues.csv', 'r') as f:
index_issues = pd.read_csv(f)
for row in index_issues.index:
item = index_issues.loc[row, 'item']
head = index_issues.loc[row, 'head']
first_letter = index_issues.loc[row, 'first_letter']
pid = ids[item]
link = index_annotation_maker(first_letter, pid, head)
index_issues.loc[row, 'reference_link'] = link
new_csv = index_issues.to_csv('index-issues.csv', index=False)
print('Index done.')
with open('num-issues.csv', 'r') as f:
num_issues = pd.read_csv(f)
for row in num_issues.index:
item = num_issues.loc[row, 'item']
entry = str(num_issues.loc[row, 'entry'])
topic = num_issues.loc[row, 'topic']
pid = ids[item]
reference = f'{entry} [{topic}]'
link = num_annotation_maker(entry, pid, reference)
num_issues.loc[row, 'reference_link'] = link
new_csv = num_issues.to_csv('num-issues.csv', index=False)
print('Numerical section done.')