Home/ Reference/ Recipes

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

Other entries in this section