-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
42 lines (35 loc) · 949 Bytes
/
main.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
# run pip install sickle
from zbsickle.app import ZbPreviewSickle
from zbsickle.models import ZbPreviewRecord
import time
import csv
import math
def log(m):
print(m)
def run(
max_records=math.inf,
outfile="out.csv",
log_interval=1000,
row_filter=lambda x: True,
fieldnames=ZbPreviewRecord.fieldnames,
):
t0 = time.time()
s = ZbPreviewSickle()
r = s.ListRecords()
i = 0
w: csv.DictWriter
with open(outfile, "w") as csvfile:
w = csv.DictWriter(csvfile, fieldnames)
w.writeheader()
for row in r:
row.fieldnames = fieldnames
added = row.writerow(w, row_filter)
if i > max_records:
return
elif added:
i += 1
if i % log_interval == 0:
current_time = time.time()
log(f"{i / (current_time - t0)} records per second")
if __name__ == "__main__":
run()