Skip missing data instead of raising
if not img_find_in: skip_cnt += 1; continue — a missing image gets counted and skipped rather than killing the whole batch.
Scenario
Skip missing data instead of raising
Notes
if not img_find_in: skip_cnt += 1; continue — a missing image gets counted and skipped rather than killing the whole batch.Python example (runnable)
Requires
pywin32. The example assumes app / doc / page / layer are already connected.
See Connection & InitPython
# data : records loaded from json in real use, via json.load(open(...))
data = [{"title": "sample point", "img_path": ""}] # fake data for the demo
skip = 0
done = 0
for item in data:
img = item.get("img_path", "")
if not img: # count missing images and skip, never abort the batch
skip += 1
print("Skipped: ", item.get("title", "Untitled"))
continue
# ... build the page ...
done += 1
print(f"Done {done}, skipped {skip}")
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
- Process in index-range batchesWith a lot of JSON records, run start/end slices and print "total / pa