-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextract_data.py
40 lines (29 loc) · 945 Bytes
/
extract_data.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
"""extract_data.py
Extract data from xlsx sheet
"""
from csv import writer
from openpyxl import load_workbook
import pandas as pd
workbook = load_workbook("data/WMCVotes.xlsx")
votes = []
wmc_memberships = pd.read_csv(
"data/wmc_list.csv",
header=0,
index_col=0,
dtype={
"Membership": bool
}
)
members_wmc = set(wmc_memberships.index)
for worksheet in workbook.worksheets:
if worksheet.title != "Members":
for cell in worksheet["A"]:
if cell.value and cell.value != "Supporters":
votes.append((worksheet.title, cell.value, "aye", ))
for cell in worksheet["D"]:
if cell.value and cell.value != "Opposers":
votes.append((worksheet.title, cell.value, "nye", ))
with open("data/votes.csv", "w", encoding="utf-8") as data:
csvwriter = writer(data)
for vote in votes:
csvwriter.writerow([*vote, vote[1] in members_wmc])