# CSV & JSON Reconciliation — Conflicts and Field Differences (`natstandridge/dataset-reconciliation`) Actor

Compare caller-owned CSV, JSON or selected Apify datasets by exact keys. Deliver complete per-key differences and source-row lineage; isolate duplicate and missing keys without fuzzy merging.

- **URL**: https://apify.com/natstandridge/dataset-reconciliation.md
- **Developed by:** [Nathaniel Standridge](https://apify.com/natstandridge) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.50 / 1,000 completed key-level reconciliations

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## 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

## CSV & JSON Reconciliation — Conflicts and Field Differences

**Find what changed between two tables without silently choosing a duplicate.** Compare caller-owned JSON, pasted CSV, or selected Apify datasets by exact single or composite keys. Get one complete dataset record per eligible key, including field differences and every contributing source-row index.

Use this after an import, between two scraper outputs, or before a downstream sync. Review ambiguous keys before making changes in the destination system. This Actor reports evidence; it does not merge records, modify source datasets, discover people, or make financial-correctness guarantees.

### Try a complete example

The prefilled example checks six keys. In the **Input → JSON** editor, this self-contained input works without credentials or external websites:

```json
{
  "leftRows": [
    {"id": "A", "value": 5},
    {"id": "B", "value": "1"},
    {"id": "D", "value": 4},
    {"id": "D", "value": 5},
    {"id": "E", "value": null},
    {"id": "L", "value": "left"},
    {"id": "", "value": "invalid key, never billed"}
  ],
  "rightRows": [
    {"externalId": "A", "value": 5},
    {"externalId": "B", "value": 1},
    {"externalId": "D", "value": 4},
    {"externalId": "E", "value": ""},
    {"externalId": "R", "value": "right"}
  ],
  "keyFields": ["id"],
  "fieldMappings": [{"left": "id", "right": "externalId"}],
  "compareFields": ["value"],
  "maxResults": 20
}
```

With sufficient charge allowance, expect these six dataset records and one free invalid-row diagnostic:

| Key | Status | Evidence |
| --- | --- | --- |
| A | `matched` | Integer 5 equals integer 5 |
| B | `different` | String `"1"` differs from integer 1 |
| D | `ambiguous` | Left rows 3 and 4 share the key; neither is selected |
| E | `different` | Null differs from an empty string |
| L | `left_only` | Key absent from the completely loaded right source |
| R | `right_only` | Key absent from the completely loaded left source |

Open the default dataset for decisions and complete lineage. Open the **summary** output for `invalidRows`, coverage, source hashes, and counts. Left row 7 appears only in `OUTPUT.invalidRows`, not in the billable dataset. This example costs **$0.003 in Actor result charges** for six records.

### Choose exactly one source per side

Each side accepts one of `leftRows` / `leftCsv` / `leftDatasetId`, and the equivalent `right…` field. An empty JSON array still counts as a selected source. **When switching from the prefilled JSON example, remove that side's `leftRows` or `rightRows` key from the input; setting it to `[]` does not remove it.** Do the same for an old CSV or dataset field when switching again. You can mix formats between sides.

#### Pasted CSV

Replace the entire example with this input to compare CSV text. CSV cells remain strings: `001` is not converted to 1, and an empty cell is not converted to null.

```json
{
  "leftCsv": "id,value\r\n001,unchanged\r\n002,left only\r\n",
  "rightCsv": "externalId,value\r\n001,unchanged\r\n003,right only\r\n",
  "fieldMappings": [{"left": "id", "right": "externalId"}],
  "keyFields": ["id"],
  "compareFields": ["value"]
}
```

Headers must be nonempty and unique; every record must have the same number of cells. Quoted commas, quoted newlines, UTF-8 BOM, CRLF and LF are supported. `csvDelimiter` explicitly chooses comma (default), semicolon, or tab; the Actor never guesses a dialect. Header-only CSV is a valid empty table. Blank text is not a CSV table.

#### Existing Apify datasets

Remove the prefilled rows keys, then select **Left Apify dataset** and **Right Apify dataset** in the input form. These resource pickers request **READ** permission only. Keep the key and field mappings appropriate for your own columns. The JSON input stores only the selected 17-character dataset IDs; never provide a token, URL, or API key in Actor input.

Use completed, stable source datasets with flat rows. The Actor reads every item, including empty objects and hidden fields, without cleaning or changing them. It checks pagination coverage plus `itemCount` and `modifiedAt` before and after reads and again before comparison. Incomplete, oversized, inaccessible, or observably changing sources fail **before any reconciliation records are written or charged**. These checks are best effort: they are not an atomic cross-dataset snapshot, and cannot rule out concurrent mutations beyond the metadata's visibility. Freeze upstream production before comparing important snapshots.

### Matching and comparison rules

- `keyFields`: one to four left/canonical field names, default `["id"]`. Composite keys preserve component boundaries and types. No fuzzy identity matching or numeric coercion occurs.
- `fieldMappings`: optional one-to-one `{ "left": "sku", "right": "product_code" }` mappings. Unmapped fields use the same name on both sides. A mapped target cannot also be consumed through an unmapped field; overlapping mappings are rejected instead of silently reading one cell twice.
- `compareFields`: omit to compare the union of all non-key fields. Specify a list to compare only those fields. An explicit `[]` checks key membership only. Output retains all selected keys and comparison fields, not unselected source columns.
- Missing field, JSON null, empty string, boolean, integer, floating-point number, and string remain distinguishable. Numeric values are the JSON values received by the Actor; upstream tools may already reserialize `1.0` as `1`. Preserve precision-sensitive identifiers and numeric spellings as strings. Integers outside ±9,007,199,254,740,991 are rejected unless supplied as strings.
- Missing, null, or empty key components make that source row invalid and uncharged. Whitespace-only strings are valid exact keys unless you opt into trimming. Boolean false and numeric zero are valid keys.
- Repeated keys are `ambiguous`, even when the rows are identical or occur on only one side. The Actor retains every contributing row and never arbitrarily pairs duplicates or reports field differences between them.
- `keyNormalization` and `valueNormalization` accept any subset of `unicode_nfc`, `trim`, `casefold`. Rules apply only to strings, in that fixed order, and default to none. Original typed values remain in lineage. Normalization collisions become ambiguous; a key normalized to empty becomes invalid.
- `includeMatched` defaults to true. Set it to false to deliver only differences, one-sided keys and ambiguous groups. Filtered matches are counted in the summary but are not charged.

### Output contract

Each default-dataset row contains:

| Field | Meaning |
| --- | --- |
| `key`, `keyId` | Typed normalized key components and SHA-256 identifier |
| `status`, `reason` | `matched`, `different`, `left_only`, `right_only`, or `ambiguous`, with an explicit decision reason |
| `leftRowIndices`, `rightRowIndices` | Every contributing source record, one-based; CSV indices exclude the header |
| `leftRecords`, `rightRecords` | Complete selected-field values for those rows; missing fields are explicit |
| `differences`, `differenceCount` | Every differing selected field for an unambiguous pair, including original and normalized compared values |
| `comparedFields`, normalization arrays | Exact comparison policy used |
| `observationId`, `sourceContextHash` | Deterministic identifiers tied to this input and source manifest, not permanent cross-snapshot record IDs |

Cells use `{ "type": "integer", "value": "1" }` or `{ "type": "missing", "value": null }`. Non-null values are represented as text alongside their explicit type. JSON is the authoritative nested evidence format. If exporting to spreadsheets, import source-derived strings as text; formula-like input is preserved, not made spreadsheet-safe.

`OUTPUT` is uncharged and includes complete-source `statusCounts`, delivered-only `deliveredStatusCounts`, `totalKeys`, `eligibleRecords`, `recordsDelivered`, `filteredMatchedRecords`, free invalid-row locations, schema presence, source row counts and content hashes. It does not copy invalid rows' contents.

**Coverage is not data quality.** `comparisonComplete=true` means both sources were fully processed. `complete=true` additionally means all requested eligible key records were delivered. An ambiguous key or invalid source row sets `hasDataIssues=true`, even if processing completed successfully. Do not treat a successful run as proof that the tables agree.

### Price and delivery limits

**$0.50 per 1,000 delivered key records ($0.0005 each); no startup fee.** A completed `matched`, `different`, `left_only`, `right_only`, or `ambiguous` key record is one billable unit. A duplicate group is one unit, not one unit per source row. Empty results, invalid-key diagnostics, filtered matches, and failures before delivery incur no Actor result charges. This Actor's platform execution usage is included in the result price; unrelated Apify subscription fees are unchanged.

`maxResults` defaults to 100 (maximum 10,000). Both tables are reconciled before applying this output limit. The Actor delivers a deterministic prefix ordered by serialized typed keys, not numeric or locale-aware order. A result, charge, or time limit sets `complete=false` and explains the stop reason; limited delivery never turns unread source rows into false one-sided decisions. Full-source counts may exceed delivered counts. Raise the limit and charge allowance for a fresh complete run; a fresh run is separately billable.

For recovery of the same run, a frozen result plan and a pending-write checkpoint prevent automatic replay of uncertain billable writes. Detailed plan records are limited by the initial result and charge allowance; full-source counts remain free. A lost write response is reconciled against retained dataset rows; an unresolved write stops instead of guessing. The Actor does not reread changing source datasets when resuming its frozen plan. Do not manually edit or delete run checkpoints or default dataset rows before recovery.

### Bounded scope

| Limit | Maximum |
| --- | --- |
| Combined source rows | 10,000 across both sides |
| Serialized input and combined source data | 3 MiB each; dataset response overhead also counts toward the source-read budget |
| Combined canonical schema | 64 fields; flat scalar values only, no nested objects or arrays |
| Field name / scalar cell | 128 / 4,096 serialized UTF-8 bytes |
| Composite key | 4 fields |
| Complete key record / frozen result plan | 1 MiB / 8 MiB |
| Selected-source API requests | 48 attempts total, including bounded read retries |
| Work budget | `maxRunSeconds` default 120, configurable 40–180; comparison phase at most 30 seconds |

Oversized complete evidence is rejected rather than truncated or sampled. Reduce selected fields or split the inputs; large duplicate groups may hit the per-record limit. Sources must already be available as caller-owned tables: no arbitrary URL downloads, scraping, or third-party enrichment services are used. Source datasets are read-only. Caller data and retained evidence use Apify run storage and its retention/access settings; avoid including unnecessary sensitive fields.

### Development and validation

The implementation uses Python's standard-library CSV/JSON processing and pinned Apify SDK 4.2.0. Runtime dependencies have a lockfile and hash-pinned export; no language model or external matching service is required.

From a source checkout: `uv run --frozen python -B -m unittest discover -s tests` runs core, source consistency, runtime, retry, and delivery regression tests. `npm ci --ignore-scripts` followed by `npm run test:schema` checks the actual official Apify schemas and examples. The local smoke and cloud-evidence validators are developer tooling, not files callers need to run the Store Actor. Local tests do not establish cloud execution cost or paid demand.

# Actor input Schema

## `leftRows` (type: `array`):

Flat JSON objects. Choose exactly one JSON, CSV or dataset source on this side. Empty arrays are valid; preserve strings, booleans, null and numbers without coercion.

## `leftCsv` (type: `string`):

UTF-8 CSV text with unique headers and consistent row widths; all cells remain strings. Remove the JSON rows field when choosing CSV.

## `leftDatasetId` (type: `string`):

Select an existing complete dataset with flat rows; READ-only scoped access. Use an exact 17-character dataset ID, never a URL or token. Remove the JSON rows field on this side.

## `rightRows` (type: `array`):

Flat JSON objects. Choose exactly one JSON, CSV or dataset source on this side. Empty arrays are valid; preserve strings, booleans, null and numbers without coercion.

## `rightCsv` (type: `string`):

UTF-8 CSV text with unique headers and consistent row widths; all cells remain strings. Remove the JSON rows field when choosing CSV.

## `rightDatasetId` (type: `string`):

Select an existing complete dataset with flat rows; READ-only scoped access. Use an exact 17-character dataset ID, never a URL or token. Remove the JSON rows field on this side.

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

One to four exact left/canonical field names. Right field names use fieldMappings. Duplicate-key groups are ambiguous; missing/null/empty components are uncharged invalid rows.

## `fieldMappings` (type: `array`):

Optional one-to-one mappings. Unmapped names compare identically named fields; overlapping mapped/fallback targets are rejected.

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

Omit to compare the union of all non-key fields. Explicit \[] compares keys only. Names are left/canonical names. Full evidence is retained for all selected fields.

## `keyNormalization` (type: `array`):

Strings only, fixed order: Unicode NFC, trim, casefold. Default preserves exact text. Normalization collisions remain ambiguous; no fuzzy or numeric coercion.

## `valueNormalization` (type: `array`):

Same explicit string-only rules for compared values. Original typed values remain in lineage. Numeric types, booleans, missing and null are never coerced.

## `includeMatched` (type: `boolean`):

Matched keys are useful completed checks and billed when delivered. Disable to return only differences, one-sided keys and ambiguous groups; skipped matches are free.

## `csvDelimiter` (type: `string`):

Explicit delimiter for both pasted CSV inputs; no heuristic dialect guessing.

## `maxResults` (type: `integer`):

Deterministic ordered prefix. Source tables are fully loaded and reconciled first; limits never manufacture absent records. Limits produce complete=false.

## `maxRunSeconds` (type: `integer`):

Includes source reads and delivery. Core computation is bounded to 30 seconds, with 25 seconds reserved for frozen-plan storage and delivery.

## Actor input object example

```json
{
  "leftRows": [
    {
      "id": "A",
      "value": 5
    },
    {
      "id": "B",
      "value": "1"
    },
    {
      "id": "D",
      "value": 4
    },
    {
      "id": "D",
      "value": 5
    },
    {
      "id": "E",
      "value": null
    },
    {
      "id": "L",
      "value": "left"
    },
    {
      "id": "",
      "value": "invalid key, never billed"
    }
  ],
  "rightRows": [
    {
      "externalId": "A",
      "value": 5
    },
    {
      "externalId": "B",
      "value": 1
    },
    {
      "externalId": "D",
      "value": 4
    },
    {
      "externalId": "E",
      "value": ""
    },
    {
      "externalId": "R",
      "value": "right"
    }
  ],
  "keyFields": [
    "id"
  ],
  "fieldMappings": [
    {
      "left": "id",
      "right": "externalId"
    }
  ],
  "keyNormalization": [],
  "valueNormalization": [],
  "includeMatched": true,
  "csvDelimiter": ",",
  "maxResults": 100,
  "maxRunSeconds": 120
}
```

# Actor output Schema

## `decisions` (type: `string`):

No description

## `summary` (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 = {
    "leftRows": [
        {
            "id": "A",
            "value": 5
        },
        {
            "id": "B",
            "value": "1"
        },
        {
            "id": "D",
            "value": 4
        },
        {
            "id": "D",
            "value": 5
        },
        {
            "id": "E",
            "value": null
        },
        {
            "id": "L",
            "value": "left"
        },
        {
            "id": "",
            "value": "invalid key, never billed"
        }
    ],
    "rightRows": [
        {
            "externalId": "A",
            "value": 5
        },
        {
            "externalId": "B",
            "value": 1
        },
        {
            "externalId": "D",
            "value": 4
        },
        {
            "externalId": "E",
            "value": ""
        },
        {
            "externalId": "R",
            "value": "right"
        }
    ],
    "fieldMappings": [
        {
            "left": "id",
            "right": "externalId"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("natstandridge/dataset-reconciliation").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 = {
    "leftRows": [
        {
            "id": "A",
            "value": 5,
        },
        {
            "id": "B",
            "value": "1",
        },
        {
            "id": "D",
            "value": 4,
        },
        {
            "id": "D",
            "value": 5,
        },
        {
            "id": "E",
            "value": None,
        },
        {
            "id": "L",
            "value": "left",
        },
        {
            "id": "",
            "value": "invalid key, never billed",
        },
    ],
    "rightRows": [
        {
            "externalId": "A",
            "value": 5,
        },
        {
            "externalId": "B",
            "value": 1,
        },
        {
            "externalId": "D",
            "value": 4,
        },
        {
            "externalId": "E",
            "value": "",
        },
        {
            "externalId": "R",
            "value": "right",
        },
    ],
    "fieldMappings": [{
            "left": "id",
            "right": "externalId",
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("natstandridge/dataset-reconciliation").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 '{
  "leftRows": [
    {
      "id": "A",
      "value": 5
    },
    {
      "id": "B",
      "value": "1"
    },
    {
      "id": "D",
      "value": 4
    },
    {
      "id": "D",
      "value": 5
    },
    {
      "id": "E",
      "value": null
    },
    {
      "id": "L",
      "value": "left"
    },
    {
      "id": "",
      "value": "invalid key, never billed"
    }
  ],
  "rightRows": [
    {
      "externalId": "A",
      "value": 5
    },
    {
      "externalId": "B",
      "value": 1
    },
    {
      "externalId": "D",
      "value": 4
    },
    {
      "externalId": "E",
      "value": ""
    },
    {
      "externalId": "R",
      "value": "right"
    }
  ],
  "fieldMappings": [
    {
      "left": "id",
      "right": "externalId"
    }
  ]
}' |
apify call natstandridge/dataset-reconciliation --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,natstandridge/dataset-reconciliation"
        }
    }
}
```

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/OjYJrGcm7tMhelIcu/builds/PSHyEISZr6jbZNDu4/openapi.json
