-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdegrees.py
118 lines (90 loc) · 2.98 KB
/
degrees.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import requests
import pandas as pd
import pprint
from auth import key
from crunch_library import pullData
url = 'https://api.crunchbase.com/api/v4/searches/degrees/'
userKey = {'user_key': key}
def degreesQuery(limit: int = 1000, uuidLast: str = '', orgList: list = []):
query = {
"field_ids": ["started_on",
"completed_on",
"identifier", # value: name of the degree
"person_identifier", # person that received the degree
"school_identifier",
"subject",
"type_name",
"updated_at",
"uuid"],
"query": [],
"limit": limit
}
return query
def flattenDegreesEntity(entity: dict):
try:
startedOn = entity['properties']['started_on']['value']
except:
startedOn = 'N/A'
try:
completedOn = entity['properties']['completed_on']['value']
except:
completedOn = 'N/A'
try:
fullDegree = entity['properties']['identifier']['value']
except:
fullDegree = 'N/A'
try:
personName = entity['properties']['person_identifier']['value']
except:
personName = 'N/A'
try:
personUuid = entity['properties']['person_identifier']['uuid']
except:
personUuid = 'N/A'
try:
schoolName = entity['properties']['school_identifier']['value']
except:
schoolName = 'N/A'
try:
schoolUuid = entity['properties']['school_identifier']['uuid']
except:
schoolUuid = 'N/A'
try:
subject = entity['properties']['subject']
except:
subject = 'N/A'
try:
degreeAttainment = entity['properties']['type_name']
except:
degreeAttainment = 'N/A'
try:
updatedAt = entity['properties']['updated_at']
except:
updatedAt = 'N/A'
entityList = [entity['uuid'],
startedOn,
completedOn,
fullDegree,
personName,
personUuid,
schoolName,
schoolUuid,
subject,
degreeAttainment,
updatedAt]
return entityList
if __name__ == '__main__':
filename = 'datasets/degrees.csv'
columnHeaders = ['uuid',
'startedOn',
'completedOn',
'fullDegree',
'personName',
'personUuid',
'schoolName',
'schoolUuid',
'subject',
'degreeAttainment',
"updatedAt"]
degreesDF = pullData(filename, url, degreesQuery(), stopRecord = 10e6, flattenFunction = flattenDegreesEntity, columnHeaders = columnHeaders)
degreesDF.to_pickle(filename + '.pickle')