-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.py
More file actions
executable file
·80 lines (68 loc) · 1.97 KB
/
Copy pathformat.py
File metadata and controls
executable file
·80 lines (68 loc) · 1.97 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
import csv
import json
files = [
"taxonomies/onet_2006.txt",
"taxonomies/onet_2009.txt",
"taxonomies/onet_2010.txt",
"taxonomies/onet_2019.txt",
]
for file in files:
template = {
"taxonomy_level_codes" : ["8"],
"taxonomies" : { "8" : []}
}
with open(file,"r") as f:
csvf = csv.DictReader(f, delimiter = '\t')
for row in csvf:
template["taxonomies"]["8"].append({
"id" : row["O*NET-SOC Code"],
"name" : row["Title"],
"description" : row["Description"]
})
with open(f"jobcoder/{file.split('.')[0]}.json","w") as fw:
json.dump(template, fw, indent = 2)
template = {
"taxonomy_level_codes" : ["6"],
"taxonomies" : { "6" : []}
}
with open("taxonomies/soc_2000.csv","r") as f:
csvf = csv.DictReader(f)
for row in csvf:
template["taxonomies"]["6"].append({
"id" : row["2000 SOC code"],
"name" : row["2000 SOC title"],
"description" : row["2000 SOC definition"]
})
with open(f"jobcoder/taxonomies/soc_2000.json","w") as fw:
json.dump(template, fw, indent = 2)
template = {
"taxonomy_level_codes" : ["6"],
"taxonomies" : { "6" : []}
}
with open("taxonomies/soc_2010.csv","r") as f:
csvf = csv.DictReader(f)
for row in csvf:
template["taxonomies"]["6"].append({
"id" : row["SOC Code"],
"name" : row["SOC Title"],
"description" : row["SOC Definition"]
})
with open(f"jobcoder/taxonomies/soc_2010.json","w") as fw:
json.dump(template, fw, indent = 2)
template = {
"taxonomy_level_codes" : [],
"taxonomies" : {}
}
with open("taxonomies/soc_2018.csv","r") as f:
csvf = csv.DictReader(f)
for row in csvf:
if row["SOC Group"] not in template["taxonomy_level_codes"]:
template["taxonomy_level_codes"].append(row['SOC Group'])
template["taxonomies"][row["SOC Group"]] = []
template["taxonomies"][row["SOC Group"]].append({
"id" : row["SOC Code"],
"name" : row["SOC Title"],
"description" : row["SOC Definition"]
})
with open(f"jobcoder/taxonomies/soc_2018.json","w") as fw:
json.dump(template, fw, indent = 2)