Home/ Reference/ Recipes

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 & Init
Python
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.

Other entries in this section