Process in index-range batches
With a lot of JSON records, run start/end slices and print "total / pages built / skipped" per batch, so a failure points at a specific range.
Scenario
Process in index-range batches
Notes
With a lot of JSON records, run start/end slices and print "total / pages built / skipped" per batch, so a failure points at a specific range.
Python example (runnable)
Requires
pywin32. The example assumes app / doc / page / layer are already connected.
See Connection & InitPython
import json
data = json.load(open("D:/data/jobs.json", encoding="utf-8"))
print("Total records: ", len(data))
for start in range(0, len(data), 10):
end = min(start + 9, len(data) - 1)
batch = data[start:end + 1] # 10 items per batch
print(f"Processing {start} to {end}, {len(batch)} items")
for item in batch:
# ... build one page at a time ...
pass
About this section: Recipes
Recipes — copy-paste ready workflows.
- This section has 6 entries; this is one of them.
- See the full section index: Recipes
Other entries in this section
- Throttling: why time.sleep(0.2) appears everywhereCorelDRAW is a single-threaded STA server. Python issues commands far
- Batch undo groupWrap big jobs in BeginCommandGroup / EndCommandGroup and one Ctrl+Z in
- Set font, read back, then fall backSee the code below. This is the most valuable pattern in the entire sc
- Verify the font before converting to curvesConverting to curves is irreversible, so the order is fixed: set the f
- Skip missing data instead of raisingif not img_find_in: skip_cnt += 1; continue — a missing image gets cou