-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrant.py
112 lines (104 loc) · 3.52 KB
/
migrant.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
import csv
def ladcodes(list):
with open('./data/de2016.csv') as f:
file = csv.DictReader(f, delimiter=',')
for row in file:
if row['OutLA'] not in list:
list.append(row['OutLA'])
elif row['InLA'] not in list:
list.append(row['InLA'])
else:
pass
def ladnames(dictionary):
if isinstance(dictionary, dict):
with open('./data/ladcodes.csv') as f:
file = csv.DictReader(f, delimiter=',')
headers = file.fieldnames
for row in file:
dictionary[row[headers[0]]] = row[headers[2]]
dictionary['S92000003'] = 'Scotland'
dictionary['N92000002'] = 'Northern Ireland'
else:
print('ladnames requires an empty dictionary')
def leavingLondon(list):
with open('./data/de2016-2.csv') as f:
file = csv.DictReader(f, delimiter=',')
for person in file:
if person['InLA'].startswith('E09'):
pass
elif person['OutLA'].startswith('E09'):
list.append(person)
else:
pass
def enteringLondon(list):
with open('./data/de2016.csv') as f:
file = csv.DictReader(f, delimiter=',')
for person in file:
if person['OutLA'].startswith('E09'):
pass
elif person['InLA'].startswith('E09'):
list.append(person)
else:
pass
with open('./data/de2016-2.csv') as g:
gFile = csv.DictReader(g, delimiter=',')
for person in gFile:
if person['OutLA'].startswith('E09'):
pass
elif person['InLA'].startswith('E09'):
list.append(person)
else:
pass
def leavingSomewhere(list, string):
with open('./data/de2016-2.csv') as f:
file = csv.DictReader(f, delimiter=',')
for person in file:
if person['InLA'].startswith(string):
pass
elif person['OutLA'].startswith(string):
list.append(person)
else:
pass
with open('./data/de2016.csv') as f:
file = csv.DictReader(f, delimiter=',')
for person in file:
if person['InLA'].startswith(string):
pass
elif person['OutLA'].startswith(string):
list.append(person)
else:
pass
def enteringSomewhere(list, string):
with open('./data/de2016-2.csv') as f:
file = csv.DictReader(f, delimiter=',')
for person in file:
if person['OutLA'].startswith(string):
pass
elif person['InLA'].startswith(string):
list.append(person)
else:
pass
with open('./data/de2016.csv') as f:
file = csv.DictReader(f, delimiter=',')
for person in file:
if person['OutLA'].startswith(string):
pass
elif person['InLA'].startswith(string):
list.append(person)
else:
pass
def genderSplit(list):
m = 0
f = 0
for person in list:
if person['Sex'] == 'F':
f += 1
else:
m += 1
print('females', f, 'males', m)
def ageSplit(list):
d = dict((x['Age'], 0) for x in list)
for person in list:
d[person['Age']] +=1
print(d)
print(d['19'])