This repository was archived by the owner on Aug 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjoin.py
More file actions
140 lines (99 loc) · 4.16 KB
/
join.py
File metadata and controls
140 lines (99 loc) · 4.16 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import csv
import os,sys,logging
import json
from tqdm import tqdm
def ege2():
data = []
empty_row = 0
with open("ege2.csv") as datafile:
dataCSV = csv.DictReader(datafile)
for row in dataCSV:
if row['address'] == "":
empty_row = empty_row + 1
data.append(row)
print("Empty addrs left: %s" % str(len([item for item in data if item['address'] == ""])))
print("Empty rows %s" % str(empty_row))
schData = []
with open('schools.csv') as schoolfile:
schCSV = csv.DictReader(schoolfile)
for row in schCSV:
schData.append(row)
for item in tqdm(data):
if item['address'] == "":
for row in schData:
if item['fullname'] == row['fullname']:
item['address'] = row['address']
empty_row = empty_row -1
print("Empty row %s" % str(empty_row))
print('Processed')
print("Empty addrs left: %s" % str(len([item for item in data if item['address'] == ""])))
schData = []
with open('schools_3.csv') as schoolfile:
schCSV = csv.DictReader(schoolfile)
for row in schCSV:
schData.append(row)
for item in tqdm(data):
if item['address'] == "":
for row in schData:
if item['fullname'] == row['FullName']:
item['address'] = row['LegalAddress']
empty_row = empty_row -1
print("Empty row %s" % str(empty_row))
print('Processed')
print("Empty addrs left: %s" % str(len([item for item in data if item['address'] == ""])))
schData = []
with open('schools_all.csv') as schoolfile:
schCSV = csv.DictReader(schoolfile, delimiter=';')
for row in schCSV:
schData.append(row)
for item in tqdm(data):
if item['address'] == "":
for row in schData:
if item['fullname'] == row['poln_name']:
item['address'] = row['yuridich_adress']
empty_row = empty_row -1
print("Empty row %s" % str(empty_row))
print('Processed')
print("Empty addrs left: %s" % str(len([item for item in data if item['address'] == ""])))
schData = []
with open('adress_all.csv') as schoolfile:
schCSV = csv.DictReader(schoolfile)
for row in schCSV:
schData.append(row)
for item in tqdm(data):
if item['address'] == "":
for row in schData:
if item['fullname'] == row['fullname']:
item['address'] = row['address']
empty_row = empty_row -1
print("Empty row %s" % str(empty_row))
print('Processed')
print("Empty addrs left: %s" % str(len([item for item in data if item['address'] == ""])))
with open("all_school_data.json", "w") as jsonfile:
json.dump(data, jsonfile)
def main():
with open("SELECT_t___FROM_schools_ege_t.csv") as datafile:
dataCSV = csv.DictReader(datafile)
data = []
for row in dataCSV:
data.append(row)
with open("SELECT_t___FROM_schools_subject_t.csv") as subjfile:
subj = csv.DictReader(subjfile)
for row in subj:
for item in data:
if row['id'] == item['subject_id']:
item['subject'] = row['alias']
data2 = []
with open("schools.csv") as addrfile:
schools = csv.DictReader(addrfile)
for row in schools:
for item in data:
#print("%s %s" % (str(row['id']), str(item['school_id'])))
if str(row['id']) == str(item['school_id']):
print("Gotcha!")
z = item.copy()
print(z)
z.update(row)
data2.append(z)
with open("all_school_data.json", "w") as jsonfile:
json.dump(data2, jsonfile)