For a report built from an authorized 2scraper export, I want evidence that the result contains the products we meant to review. A row count is useful, but ten rows can contain nine requested products and one unrelated one. That matters when a forecast or an audit treats the file as complete. I start with the expected set of product keys, then compare it against the observed identities and keep the differences available for review.
Written with AI assistance. All product keys and report scenarios here are synthetic. The Python example was run locally, and the cover was prepared with AI assistance.
Treat the request as a source artifact
An approved filter can come from a product list, a frozen category snapshot, or a business rule applied to a dated candidate set. Preserve the input that actually supplied the expected products. If the expected set is reconstructed later from a changing catalog, a valid earlier export can look incomplete simply because the current request includes a new product. Give the request a version and record the observed date and product grain.
I would use strings for product keys. If a source has two stores with independent IDs, the combination of store and item may be the stable key. A leading zero can separate two identifiers in a real catalog, and importing the field as a number can erase that distinction. Specify the accepted key before comparing or deduplicating rows.
The team also needs to decide whether it expects one row per product or a collection of observations. The toy example models one row per requested product. A report with multiple offers or daily snapshots could legitimately contain several rows for one product. In that case, check membership at the product level and audit duplicates at the lower grain using the additional dimensions required by that report.
Walk through an equal-count failure
Assume an internal report requests products 007, 012, and 021. A trial export returns 007, 012, and 035. It has exactly three rows, but one requested product is absent and one unexpected product is present. A second export contains 007, 007, and 012. That export also has three rows. It is missing 021 and includes an extra observation of 007 under the one-row-per-product contract.
The local checker deliberately returns each kind of difference as its own field. The observed export arrives as a list so duplicates remain visible. An authoritative expected set can be validated separately. The example rejects duplicate keys in the expected list, because a request containing the same key twice needs a clearer definition before the reviewer can evaluate its coverage.
from collections import Counter
def validate(keys):
if any(not isinstance(key, str) or not key or key.strip() != key for key in keys):
raise ValueError("invalid product key")
def reconcile(expected, observed):
expected = tuple(expected)
observed = tuple(observed)
validate(expected)
validate(observed)
wanted = set(expected)
if len(wanted) != len(expected):
raise ValueError("duplicate request key")
counts = Counter(observed)
found = set(counts)
return {
"missing": sorted(wanted - found),
"extra": sorted(found - wanted),
"duplicates": {key: counts[key] for key in sorted(counts) if counts[key] > 1},
"matched": len(wanted & found),
}
wanted = ["007", "012", "021"]
assert reconcile(wanted, ["007", "012", "035"]) == {
"missing": ["021"], "extra": ["035"], "duplicates": {}, "matched": 2}
assert reconcile(wanted, ["007", "007", "012"])["duplicates"] == {"007": 2}
assert reconcile(wanted, reversed(wanted)) == {
"missing": [], "extra": [], "duplicates": {}, "matched": 3}
assert reconcile(["007"], ["7"])["missing"] == ["007"]
assert reconcile([], [])["matched"] == 0
print("Equal counts did not hide missing 021, extra 035, or duplicate 007")
The local run printed Equal counts did not hide missing 021, extra 035, or duplicate 007. Reordering the expected keys produces a complete result with the same membership. The last checks establish how the script handles distinct string IDs and an empty input. In a production dashboard, evidence that an empty request was intentional belongs with the request.
Separate scope exclusions from missing evidence
Sometimes a product was deliberately excluded after the approved request, for example when an input record supplied a recognized discontinued status. That is a legitimate scope change only when its evidence and effect are recorded. Keep the original request and the approved excluded keys. Then the reviewer can compare what actually happened with the updated scope and still see the difference from the original intention.
A product that was requested but has no trustworthy row is different from one that was explicitly excluded. If a dashboard turns both into a blank cell, a colleague may assume the product was intentionally unobserved. I would give the missing record an unresolved label and expose the reason where the source supports it. A missing row is also different from a real row whose price or availability field is absent. The first is a membership question and the second is field coverage.
One reconciliation view could show 100 requested, three approved exclusions, 94 matched, and three unresolved. A separate row can report unexpected products or duplicates. Those quantities are easier to reconcile than a single percentage. They also let an owner isolate whether the discrepancy came from scope, retrieval, or the adapter that selects the exported fields.
Keep the identity contract stable through an import
If the underlying export includes a supplier ID and a platform ID, write down which one the report matches. An adapter can accidentally swap a field while preserving an apparently valid string. Make a fixture that gives those identities different values. Now an end-to-end mapping test can reveal an error that neither a row count nor a strict string parser notices.
Decide how to represent combinations without collisions. A structured pair of store and item identifiers retains their boundaries. Concatenating them with a separator can be ambiguous if either field also permits that separator. Keep the source fields separately and build the set at the intended grain. Document any normalization such as case handling before grouping, and retain the observed spelling.
I would also test a record that changes the candidate category while keeping its product identity. A category-specific report could consider that a scope change. A product-history report might still include it and put the updated category into a descriptive field. The expected set needs to be constructed for the same question the export is meant to answer.
Compare early enough to keep unverified records out of the totals
The check is most useful before an aggregation. Suppose the unexpected row has the highest price. If it enters an average or a price band before the membership audit, the entire report may already reflect an unapproved product. Apply the intended scope to a labeled accepted set and keep the held records in a separate review output.
Some teams may prefer to block a partial import entirely. Others can publish a provisional result using only the matched population. Write down the rule and show the matched count with any result that is published provisionally. A new report can preserve the valid subset without pretending that all requested products were included. Use the reporting deadline and the available evidence to determine how to handle a partial view.
An exception table can carry the approved request ID, the source batch, the type of exception, and the product or review reference. Use ordinary labels such as expected but missing and seen more than once. When a colleague can select the next evidence source from the label, the test helps resolve problems rather than merely stopping an import.
Test what happens across repeated runs
Run the same approved request twice against the same fixed fixture. Verify that the missing and extra sets are identical, independent of row order. Then add a legitimate new product to the dated request and rerun under a new request version. The comparison should identify that it describes a different population. Keep both outputs together only if the report records which scope each one used.
For a paginated authorized export, test a batch where two adjacent pages share one key and another page omits one requested key. A resulting count can conceal the offset. Check membership against the whole expected set and inspect duplicates under the report's declared grain. More than one record for a key can be valid before the enforced stage, so put the test at the boundary where one row per key is promised.
Decide how to report an unexpected completely empty export. If the request contained items, the missing set should list them. If the approved request was itself empty, a successful comparison is possible. The overall process still needs evidence that it read the expected source rather than treating a failed download or an absent file as an intentionally empty set.
Use a small sample to exercise exception handling itself
I would keep three requests in the regression suite. The first asks for a complete set and produces a complete file. The second drops one item that was eligible at the cutoff. The third includes a documented exception where the request changed after approval. Confirm that the release notes name the expected set for each case and never mark the second as complete only because its rows are individually valid.
Next, test a discrepancy capable of affecting a downstream decision. Imagine the unexpectedly included item is the only one in a high price band. Its presence can create a false category signal even if the total number of exported rows never changes. An acceptance test can calculate the band from the matched set and check that the exception remains available for review without entering the published aggregate.
For a membership report used by another team, make one handoff with no access to the raw export. Give the next reviewer sufficient approved metadata to tell what changed and which source owner can help. The status should distinguish a request with no eligible products from a missing export and a real exclusion. If the same summary label covers all three cases, an operator cannot reliably choose the right next action.
Review one discrepancy before widening the report
Start with one controlled group and a synthetic file whose row count matches while membership does not. Give a colleague only the review output and ask them to identify the missing, extra, and repeated items. Then ask which records are eligible for the chart. If the answer depends on a guess about the scope, add the request version and policy note to the report.
Choose a project in 2scraper and use its documented output fields to select a controlled input for your own check. Start with one dated request and independently verified product keys. A repeatable membership check can make a catalog update useful for review before you expand it to more categories or a recurring dashboard.
Further reading
Check Price and Stock Units in a 2scraper Catalog Export explains what to check once the intended rows reach the catalog.
Check Product Links Before Adding an Amazon Scraper Export to a Report checks how the displayed evidence connects back to each included item.
Keep Parent Product IDs Out of an Amazon Scraper Variant Price Join shows why a validated product set still needs the right observation grain before prices are joined.
Top comments (0)