-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplitJson.py
More file actions
24 lines (21 loc) · 944 Bytes
/
Copy pathsplitJson.py
File metadata and controls
24 lines (21 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
import json
#you need to add you path here
with open(os.path.join('C:/Users/vanev/Dropbox/PC/Documents/Respaldos Proyectos/Develop/AAT Getty/', 'data.json'), 'r',
encoding='utf-8') as f1:
lla = [json.loads(line.strip()) for line in f1.readlines()]
#
#this is the total length size of the json file
print(len(lla))
for lle in lla[0].values():
ll = lle['Subject']
#in here 2000 means we getting splits of 2000 tweets
#you can define your own size of split according to your need
size_of_the_split=2000
total = len(ll) // size_of_the_split
#in here you will get the Number of splits
print(total+1)
for i in range(total+1):
json.dump(ll[i * size_of_the_split:(i + 1) * size_of_the_split], open(
"C:/Users/vanev/Dropbox/PC/Documents/Respaldos Proyectos/Develop/AAT Getty/" + str(i+1) + ".json", 'w',
encoding='utf8'), ensure_ascii=False, indent=True)