# Compare Two Tables - Changes & Duplicate IDs (`posh_brewery/crm-import-audit-snapshot-guard`) Actor

Compare two CSV tables or Apify datasets. See new rows, changed values, missing rows, duplicate IDs and empty required fields. Download an Excel, CSV, JSON or HTML report. No developer fee; Apify usage costs may apply.

- **URL**: https://apify.com/posh_brewery/crm-import-audit-snapshot-guard.md
- **Developed by:** [SSS YYS](https://apify.com/posh_brewery) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Compare Two Tables - Changes & Duplicate IDs

**Find out what's new, what's changed, and which rows need checking.**

Give this tool an older table and a newer table. It compares the rows and creates a report you can read in your browser or download as Excel, CSV or JSON. Use two CSV tables, two Apify datasets, or two lists of JSON rows.

**No developer fee in this release.** Apify may charge for the computing and storage used by your run. Check the Pricing tab before running.

### What will it find?

| In your tables | In your report |
|---|---|
| A new product or contact appears | A new row |
| A price changes from 100 to 90 | The old value and the new value |
| An old ID is absent from the latest table | A row not found in the latest table |
| The same ID appears more than once | Duplicate IDs to review |
| A column you marked as required is empty | A missing-information warning |

**Duplicate rows are flagged for you to review, not automatically deleted.** A row missing from the latest table does not prove a product was removed, a property was sold, or a job was closed.

### Try it before using your own data

1. Click **Try for free**.
2. Keep **Try the example** selected and click **Start** (or **Save & start**).
3. In **Output**, choose **Open the report**. You can also download the Excel report.

The built-in example uses made-up data. It shows one new row, one changed row, one row not found in the latest table, duplicate IDs and a missing email. You don't need to provide customer data to try it. The example has no developer fee; Apify resource usage may still apply.

### A simple example

Yesterday, product **A1** cost **100**. Today it costs **90**. Product **C3** is absent, and product **D4** is new.

| ID | Older price | Newer price | Result |
|---|---:|---:|---|
| A1 | 100 | 90 | Changed: 100 → 90 |
| B2 | 40 | 40 | No change |
| C3 | 25 | — | Not found in the newer table |
| D4 | — | 60 | New row |

The report keeps the original values so you can check them before updating another system. This table is an illustration; the built-in example also includes duplicate IDs and a missing required field.

### Compare your own tables in three steps

#### 1. Choose where your two tables come from

| Choose | What to provide |
|---|---|
| **Compare two CSV tables** | Paste the older CSV and newer CSV, including the column names in the first line. |
| **Choose two Apify datasets** | Select an older dataset and a newer dataset you have permission to read. |
| **Paste two JSON lists** | Paste the older rows and newer rows as JSON arrays. |

If your tables are in Excel, save them as CSV first. This version accepts pasted CSV text, not direct `.xlsx` uploads. It reads the two tables you supply; it does not visit websites or automatically find a previous run for you.

#### 2. Tell it which column identifies each row

Choose a stable ID column that exists in both tables, such as `id`, `productId` or `listingId`. For example, enter `id` in **Which column identifies each row?**

You can combine columns, such as `source` and `listingId`, when neither column is unique on its own. Column names must match your table exactly.

Optionally, choose columns that must not be empty, or ignore columns that change on every run, such as `scrapedAt`.

#### 3. Run and download the report

Click **Start**. Open the report in **Output**, or download `report.xlsx`, `changes.csv`, `issues.csv` or `report.json`. The tool does not update your original datasets or your CRM.

### When is this useful?

- **Product lists:** review new products and price changes between two exports.
- **Contact lists:** check changed details, repeated IDs and empty required columns before a CRM import.
- **Property or job lists:** see what changed between two sets of collected data. Missing rows need further checking.
- **Repeated exports:** compare two runs without manually checking every row.

### Questions before you start

**Does it remove duplicates?**

It flags duplicate IDs. If an ID repeats in either table, that ID is left out of matching on both sides. You get the details to review; the tool does not choose which duplicate is correct.

**Does it check whether an email is real?**

No. It can flag an empty email column if you mark it as required. It does not verify email delivery or fill in missing contact details.

**Does it send my tables to an AI service?**

This code makes no LLM calls and sends no records to external AI, email or analytics services. It reads your selected inputs and writes reports to the run's Apify storage. Use data you are authorized to process and apply your usual storage-access and retention settings.

**Is it free?**

There is no developer report fee in this release, including when you compare your own data. Apify computing and storage costs may apply. A **Try for free** button does not mean unlimited resource usage is free. Any future developer pricing would be disclosed through Apify before taking effect; past free usage will not be charged retroactively.

### 中文说明

这是一个“比较两份表，找出变化”的工具。提供旧表和新表，指定用哪一列识别同一条记录，例如商品编号，就能查看新增记录、内容变化、这次没出现的记录、重复编号，以及你要求填写却为空的信息，并下载 Excel、CSV、JSON 或网页报告。

第一次使用可以直接选择示例，不用上传真实客户数据。重复记录只会被标记，不会自动删除；没有出现的记录也不能直接认定为已删除。当前免开发者服务费，Apify 平台资源费用仍可能产生。

### API example: compare CSV text

```json
{
  "inputMode": "csv",
  "keyFields": ["id"],
  "beforeCsv": "id,price\nA1,100\nB2,40\nC3,25\n",
  "afterCsv": "id,price\nA1,90\nB2,40\nD4,60\n",
  "exportXlsx": true
}
```

For dataset inputs, use `inputMode: "datasets"` with `beforeDatasetId` and `afterDatasetId`. For JSON lists, use `inputMode: "inline"` with `beforeItems` and `afterItems`. `inputMode: "demo"` runs the built-in example.

### Advanced details

The remaining sections explain exact comparison rules, output formats and size limits. You can leave the advanced options unchanged for a first comparison. The built-in demo uses its own fixed columns and rules; only `maxRows` and `exportXlsx` affect that example run.

### Comparison rules

- Field names are literal **top-level** names. A dot in a name is not a nested-path expression.
- JSON types are strict by default: `"1"`, `1`, `1.0` and `true` are distinct. Missing fields differ from explicit `null`.
- `trimStrings` ignores surrounding whitespace for equality, keeping original values in the report.
- `numericFields` explicitly allows exact numeric equality such as `"100.00"` and `100`. Currency symbols and thousands separators are not guessed. Boolean values never become numbers.
- `casefoldFields` explicitly allows case-insensitive string equality, for example email. Do not apply it to case-sensitive identifiers.
- `compareFields` limits comparison to named fields; an omitted or empty list compares all fields except `ignoreFields`.
- Records are not enriched, inferred or modified. There is no fuzzy identity matching, email deliverability check, or LLM call.

### Downloads and integrations

Every successful run saves:

- `report.json`: full report with original JSON values; the canonical output.
- `report.html`: escaped, self-contained report showing up to 100 rows per section and bounded cell previews.
- `changes.csv`: one row per changed field, or one row for an added/not-observed record.
- `issues.csv`: import-quality issues.
- `report.xlsx`: Summary, Changes and Issues sheets, unless disabled.

The default dataset contains change and issue records with a `record_type` field. You can read it from the Apify API or connect it to n8n, Make or your existing workflow. Run this Actor after your scraper finishes and supply the two snapshots explicitly; version 1 does not silently choose a baseline or retain one across runs.

CSV fields with potentially executable spreadsheet prefixes are neutralized. Excel cells are written as strings, with control characters visibly escaped. Excel's 32,767-character cell limit is handled with an explicit truncation marker; the full value stays in `report.json`. The CSV is intended for human review; use JSON when exact types and original values must be preserved.

### Limits and usage costs

- Default: 10,000 rows per input; configurable to 25,000.
- Maximum 16 MiB of JSON per snapshot, 512 KiB per record and 1,000 top-level fields per record. Platform input limits can be lower for inline text; use datasets for larger jobs.
- Maximum 50,000 event/issue records and 50,000 flattened change rows.
- Maximum 32 MiB JSON report and 64 MiB combined exports.
- A limit violation fails clearly. Inputs are never silently sampled or incomplete reports billed as complete.

This public test release charges **no developer fee**, regardless of the number of changes. Apify compute and storage usage may still apply to the account running the Actor. There is no bank-account requirement to try this version. Future pricing changes, if any, will be shown through Apify's pricing and notification process; past free usage will not be billed retroactively.

Input datasets are never changed. Reports are written to storage belonging to the run. This code sends no record data to external AI services, email services, analytics or arbitrary websites. Keep private datasets private and apply your usual Apify storage retention and access settings.

### Local development

Requires Python 3.11+. Install `requirements.txt`, then:

```sh
PYTHONPATH=src python -m unittest discover -s tests -v
PYTHONPATH=src python -m snapshot_guard.cli --input examples/demo-input.json --output-dir demo-output
```

The offline CLI does not support remote dataset IDs. The Apify entrypoint is `python -m snapshot_guard.main`. No separate API key input is required; dataset access uses the run's authorized Apify credentials and selected read-only resources.

### Feedback

Use the Actor's Issues tab for reproducible problems. Include the input mode, a small synthetic example and the expected result. Do not post private customer data, passwords or API tokens.

# Actor input Schema

## `inputMode` (type: `string`):

Try the example without providing your own data, or choose CSV tables, Apify datasets or JSON lists. No developer fee; Apify resource costs may apply.

## `keyFields` (type: `array`):

For your own data, enter a stable column name found in both tables, such as id or productId. Add more columns for a combined ID. Repeated IDs are flagged for review. The example uses its own IDs.

## `beforeCsv` (type: `string`):

Paste the older CSV, including column names in the first line. In Excel, save the sheet as CSV and paste its text here.

## `afterCsv` (type: `string`):

Paste the newer CSV with its column names. Only used when you choose Compare two CSV tables.

## `beforeDatasetId` (type: `string`):

Choose the earlier dataset you are allowed to read. It is never modified. Only used in dataset mode.

## `afterDatasetId` (type: `string`):

Choose the later dataset you are allowed to read. It is never modified. Only used in dataset mode.

## `beforeItems` (type: `array`):

Paste a JSON array of row objects. Only used when you choose Paste two JSON lists.

## `afterItems` (type: `array`):

Paste the newer rows as a JSON array. Only used in JSON-list mode.

## `requiredFields` (type: `array`):

Optional. Enter column names such as name or email. The report flags missing, null or blank values in the newer table. Zero and false are valid.

## `compareFields` (type: `array`):

Optional. Leave empty to compare all columns except those you choose to ignore.

## `ignoreFields` (type: `array`):

Optional. Skip columns that change every run, such as scrapedAt. Required-column checks still apply.

## `numericFields` (type: `array`):

Optional. Enter columns where plain numeric strings and numbers should compare as equal. Currency symbols and commas are not guessed.

## `casefoldFields` (type: `array`):

Optional. Useful for values such as email addresses. Original values stay in the report. Avoid case-sensitive IDs.

## `trimStrings` (type: `boolean`):

Ignore surrounding spaces when comparing text. Original values remain in the report. The example uses fixed rules.

## `includeUnchanged` (type: `boolean`):

Also export unchanged rows. The summary always counts them. The built-in example omits them from the row output.

## `maxRows` (type: `integer`):

Default 10,000; maximum 25,000. The run fails clearly above this limit instead of skipping rows. Each table is also limited to 16 MiB of JSON.

## `exportXlsx` (type: `boolean`):

Also creates JSON, CSV and HTML reports. Very long Excel cells are visibly shortened; the full value stays in report.json.

## Actor input object example

```json
{
  "inputMode": "demo",
  "keyFields": [
    "id"
  ],
  "trimStrings": true,
  "includeUnchanged": false,
  "maxRows": 10000,
  "exportXlsx": true
}
```

# Actor output Schema

## `report` (type: `string`):

No description

## `excel` (type: `string`):

No description

## `json` (type: `string`):

No description

## `changesCsv` (type: `string`):

No description

## `issuesCsv` (type: `string`):

No description

## `records` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "keyFields": [
        "id"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("posh_brewery/crm-import-audit-snapshot-guard").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "keyFields": ["id"] }

# Run the Actor and wait for it to finish
run = client.actor("posh_brewery/crm-import-audit-snapshot-guard").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "keyFields": [
    "id"
  ]
}' |
apify call posh_brewery/crm-import-audit-snapshot-guard --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,posh_brewery/crm-import-audit-snapshot-guard"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/dEhDC3RodeXbMLthq/builds/dud8UziLFDB7tVgvm/openapi.json
