-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_SBIRjson.py
executable file
·64 lines (41 loc) · 1.42 KB
/
merge_SBIRjson.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 20 10:43:27 2021
Join manually downloaded JSON files into one full file for SBIR.gov data
De-duplicate in case there were any downloading errors.
@author: sethschimmel
"""
import json
import os
path = "/Users/sethschimmel/Documents/GitHub/CUNY-Capstone/data/sbir/raw_awards_data"
files = os.listdir(path)
files = [x for x in files if x.endswith(".json")]
files = [os.path.join(path,file) for file in files]
data = []
for file in files:
with open(file, encoding="utf-8") as f:
data.append(json.load(f))
fulldata = []
with open("sbir_2008to2018.json", "w",encoding="utf-8") as outfile:
for f in files:
with open(f, 'rb') as infile:
file_data = json.load(infile)
fulldata += file_data
json.dump(fulldata, outfile)
######### merge topics jsons
path = "/Users/sethschimmel/Documents/GitHub/Capstone/data/sbir/definitions_dictionaries"
files = os.listdir(path)
files = [x for x in files if x.endswith(".json")]
files = [os.path.join(path,file) for file in files]
data = []
for file in files:
with open(file) as f:
data.append(json.load(f))
fulldata = []
with open("sbirTopics_2008to2018.json", "w") as outfile:
for f in files:
with open(f, 'rb') as infile:
file_data = json.load(infile)
fulldata += file_data
json.dump(fulldata, outfile)