forked from daltondo/Sumerian-network-graph-data
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode_creator.py
More file actions
40 lines (32 loc) · 1008 Bytes
/
node_creator.py
File metadata and controls
40 lines (32 loc) · 1008 Bytes
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
import csv
import node_merger
import data_handler
import edge_creator
from collections import defaultdict
# key: (person, profession), value: list of Nodes
person_to_info = defaultdict(list)
# container to store row data
class Node:
def __init__(self, name, role, profession, p_index, year):
self.name = name
self.role = role
self.profession = profession
self.p_index = p_index
self.year = year
self.id = None
def add_id(self, id):
self.id = id
### OPEN full_roles_profs.csv TO READ ###
# traverses through names_roles_professions to create a node per row
def create_nodes_list():
with open('full_roles_profs.csv', 'rt') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
name = row['name']
role = row['role']
profession = row['profession']
p_index = row['p id']
year = row['year']
person = (name, profession)
node = Node(name, role, profession, p_index, year)
person_to_info[person].append(node)