forked from daltondo/Sumerian-network-graph-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_handler.py
More file actions
46 lines (37 loc) · 1.38 KB
/
data_handler.py
File metadata and controls
46 lines (37 loc) · 1.38 KB
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
import csv
import node_creator
import node_merger
import edge_creator
from collections import defaultdict
# traverses through new_person_to_info to fill out p_indexes_to_people (a dict of p_indexes to people in the p_indexes)
def fill_new_person_to_info():
for person, node in node_merger.new_person_to_info.items():
roles = node.role
p_indexes = node.p_index
years = node.year
for i in range(len(roles)):
curr_p_index = p_indexes[i]
curr_role = roles[i]
container = (person, curr_role, i)
node_merger.p_indexes_to_people[curr_p_index].append(container)
# acquires list of texts where there were only 1 participants
def find_single_participant_texts():
list_of_single_participant_texts = []
for key, value in node_merger.p_indexes_to_people.items():
if len(value) == 1:
list_of_single_participant_texts.append(key)
return list_of_single_participant_texts
# finds p_indexes where there are more than 5 people involved in the transaction
def find_multiple_transactions():
with open('multiple_transactions.csv', 'w') as csvfile:
fieldnames = ['p_index', 'people_involved']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for key, value in node_merger.p_indexes_to_people.items():
if len(value) >= 5:
p_index = key
people_involved = value
writer.writerow({
'p_index': p_index,
'people_involved': people_involved
})