-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation_dev.py
46 lines (35 loc) · 1.03 KB
/
simulation_dev.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
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 23 20:57:41 2022
@author: Memen
@edited: Daker
"""
import json
import time
import argparse
import random
import uuid
with open("../tweets.json", 'r', encoding='UTF-8') as f:
data = json.load(f)
steps = 20
startIndex, endIndex = 0, 0+steps
print(type(data))
print(len(data))
# keys= list(data.keys())
try:
while(data[startIndex] != None):
print("********************")
pre = random.randint(0, len(data))
with open("./test-{}.json".format(pre), 'w') as o:
for item in list(data[startIndex:endIndex]):
item["uuid"] = str(uuid.uuid4())
o.write(json.dumps(item)+'\n')
print(item)
o.close()
print("********************")
startIndex = endIndex
endIndex = startIndex+steps
time.sleep(40)
except Exception as e:
print(e)
f.close()