Back to cookbook

AI Prompt to Merge and Reconcile Two Datasets With Mismatched Columns

0 views Updated

Make this prompt yours

Share

This AI prompt is for anyone who needs to merge two datasets that don't line up cleanly — different column names, inconsistent formatting, or fields that only partially overlap. It's built for analysts, operations staff, and anyone combining exports from two systems (an old CRM and a new one, two regional sales files, a vendor list and an internal one) where a simple spreadsheet merge would silently drop or duplicate rows.

Rather than asking the model to "combine these," the prompt has it first map each column in dataset A to its equivalent in dataset B (or flag that no equivalent exists), then reconcile mismatches like "Customer Name" versus "Client" or dates stored as MM/DD/YYYY in one file and YYYY-MM-DD in the other. It also asks the model to call out records that can't be confidently matched instead of guessing, which is the step that prevents a merged file from quietly combining two different people who happen to share a name.

This works well for datasets you can paste directly into the chat, but once either file runs to thousands of rows, context limits start to bite and the model can lose track of which rows it already reconciled. For that case, pulling just the overlapping columns or a representative sample out of each file first with Context Extractor keeps the reconciliation prompt focused on the data that actually needs matching, rather than the whole file.

Prompt template

Make this prompt yours

prompt-template
362 tokens
You are a data integration specialist merging two datasets that use inconsistent structures. Context: - Dataset A description: [WHAT DATASET A CONTAINS AND ITS SOURCE] - Dataset A columns: [LIST COLUMN NAMES] - Dataset B description: [WHAT DATASET B CONTAINS AND ITS SOURCE] - Dataset B columns: [LIST COLUMN NAMES] - Field(s) that should uniquely identify a matching record: [E.G. EMAIL, CUSTOMER ID, OR NAME + DATE OF BIRTH] - Dataset A sample: [PASTE DATA HERE] - Dataset B sample: [PASTE DATA HERE] Task: 1. Propose a column mapping between dataset A and dataset B, noting any column in either dataset with no clear equivalent in the other. 2. Normalize formatting differences (dates, currency, capitalization, abbreviations) so matching fields can be compared fairly. 3. Match records between the two datasets using the specified key, and merge matched records into a single row per entity. 4. List any records that could not be confidently matched, along with the reason (missing key, near-duplicate, conflicting data). 5. Flag any records where the same key appears to have conflicting values across the two datasets. Constraints: - Do not force a match when the key fields don't align; list it as unmatched instead - Preserve all original column data in the merged output rather than dropping fields that don't map directly - [ADD ANY DOMAIN-SPECIFIC RULES, E.G. "TREAT 'INC' AND 'INCORPORATED' AS THE SAME COMPANY SUFFIX"] Output format: - A proposed column mapping table (Dataset A column, Dataset B column, Notes) - A merged table of matched records - A separate list of unmatched or conflicting records with the reason for each

Want it sharper? Optimize this prompt with Prompt Optimizer, check it with the Prompt Debugger or shorten it with the Token Optimizer.

Example input

example-input
210 tokens
Dataset A description: Current CRM export of active customers. Dataset A columns: customer_id, full_name, email, signup_date, plan Dataset B description: Legacy billing system export. Dataset B columns: Client ID, Client Email, Joined On, Subscription Tier Matching key: email address Dataset A sample: customer_id,full_name,email,signup_date,plan C1001,Maria Gomez,maria.gomez@email.com,2024-03-14,Pro C1002,David Lin,d.lin@email.com,2023-11-02,Basic C1003,Priya Shah,priya.shah@email.com,2025-01-20,Pro Dataset B sample: Client ID,Client Email,Joined On,Subscription Tier B-55,maria.gomez@email.com,03/14/2024,Professional B-61,d.lin@email.com,11/02/2023,Starter B-70,p.shah@email.com,01/20/2025,Professional

When to use it

  • Combining exports from two different systems that store the same information under different column names
  • Merging datasets where dates, currencies, or categories are formatted inconsistently between files
  • Reconciling a vendor, customer, or employee list against an internal system of record before an import
  • Checking whether two datasets that should describe the same entities actually agree with each other

Best practices

  • Provide the full column headers from both datasets, not just the rows, so the model can map fields first
  • Tell the model which column (or combination of columns) should be treated as the unique key for matching
  • Ask it to list unmatched or ambiguous records separately instead of forcing every row into a match
  • Specify the output structure you need, such as a single merged table versus a side-by-side comparison

Common mistakes

  • Letting the model guess column mappings silently instead of asking it to confirm the mapping first
  • Assuming a name or ID match is always correct without checking for near-duplicates or typos
  • Not specifying how to handle rows that exist in one dataset but not the other
  • Merging large files in one pass without checking a sample of the output for mismatched or dropped rows

FAQs

How do I merge two spreadsheets that use different column names for the same data?

Give the model both sets of column headers before any row data and ask it to propose a mapping first. Confirming the mapping before merging prevents it from guessing silently, which is the most common way a merge ends up combining the wrong fields.

What should I do when two datasets have no reliable shared ID to match on?

Pick the closest available combination, such as name plus date of birth or email plus signup date, and explicitly tell the model to flag anything it can't match with high confidence rather than forcing a match. Reviewing the unmatched list manually is faster and safer than trusting a guessed match.

Can AI models like ChatGPT or Claude actually detect conflicting data between two merged records?

Yes, when both values are included in the data you provide, the model can compare them directly and flag disagreements, such as two different signup dates for what looks like the same customer. It can't verify which value is correct on its own, so treat conflict flags as something to check against the source system rather than a final answer.

What tool can help if my two datasets are too large to paste into one prompt?

Context Extractor — pulls the relevant columns or a representative sample out of each large file first, so this reconciliation prompt can focus on matching records instead of running out of room for the full datasets.

Found this prompt useful? Share it.

Share

More in Data Analysis

Data Analysis

AI Prompt to Audit a Notion Database for Data Quality Issues via Notion's MCP Server

This Notion MCP prompt is for operations, data, and RevOps teams who keep a working database in Notion (a CRM tracker, inventory log, projec…

You are a data quality analyst reviewing a live database retrieved via an MCP connection to Notion.

Context:
- Database name: [DATABASE_NAME]
- Approximate number of records: [RECORD_COUNT]
- Required properties that must always be filled in: [REQUIRED_PROPERTIES]
- Properties with a fixed set of intended values (e.g. Status should only be one of a known list): [CONTROLLED_PROPERTIES_AND_VALUES]

Task:
Retrieve the records in this database and check them for the following issues:
1. Missing values in required properties
2. Duplicate records (same entity represented more than once)
3. Inconsistent formatting or casing in controlled properties
4. Broken or empty relation fields
5. Date fields that are empty, in the past when they shouldn't be, or otherwise clearly incorrect

Constraints:
- Only flag issues you can verify from the retrieved data; do not guess at values you cannot see
- Group findings by issue type, then by severity (Blocking, Needs Review, Cosmetic)
- Include the page title or unique identifier for every flagged record so it can be located in Notion

Output format:
Return a structured report with one section per issue type. Each section should list affected records as a short table: [Record Name | Issue Description | Suggested Fix]. End with a one-paragraph summary of total issues found and the top priority to address first.

Make this prompt yours

Data Analysis

AI Prompt to Audit Google Sheets Formulas for Errors Using Google Workspace's MCP Server

This prompt turns an AI assistant into a spreadsheet auditor that can read a live Google Sheet through Google Workspace's MCP server and sys…

ROLE
You are a meticulous spreadsheet auditor with deep expertise in Google Sheets formulas, functions, and data integrity, connected to the live sheet via an MCP server.

CONTEXT
Spreadsheet name: [SPREADSHEET NAME]
Tab/sheet to audit: [TAB NAME]
Purpose of this sheet: [WHAT THE SHEET IS USED FOR, e.g. "monthly revenue forecast shared with the finance team"]
Known manual-override columns (do not flag as errors): [LIST OF COLUMNS OR "NONE"]
Date or version this sheet was last fully reviewed: [DATE OR "NEVER"]

TASK
Using the MCP connection, read every formula in the specified tab and identify:
1. Broken references (#REF!, #VALUE!, #N/A, #DIV/0! and similar error values)
2. Formulas that reference a range which no longer matches the data (e.g. a SUM or VLOOKUP range that stops short of new rows)
3. Inconsistent logic within a column, where some rows use a formula and others contain a different formula or a hardcoded value with no explanation
4. Circular references or formulas that indirectly depend on their own output

CONSTRAINTS
- Do not flag the manual-override columns listed above as errors
- Quote the exact formula text and cell address for every issue found
- Do not rewrite or change any formulas in the sheet; only report findings
- If a formula's intent is ambiguous, say so explicitly rather than guessing what it was supposed to do

OUTPUT FORMAT
Return a table with these columns: Cell Address | Formula Found | Issue Type | Explanation | Suggested Fix (if obvious)
Follow the table with a short summary: total issues found, how many are broken references vs. logic inconsistencies, and which columns need the most attention.

Make this prompt yours

Data Analysis

AI Prompt to Audit Shopify Inventory and Listings via MCP

This is a prompt for Shopify store owners using Shopify's Admin MCP server , which connects your store's product, inventory, and order data…

Using the Shopify Admin MCP connection to my store, run a catalog audit with these checks:

1. Flag any product with inventory below [STOCK THRESHOLD] units.
2. Flag any product missing [REQUIRED FIELD(S), e.g. description, product type, metafield name].
3. Flag any product whose tags don't follow this convention: [YOUR TAGGING RULE].
4. Flag any product with variants that have mismatched or missing pricing.

For each flagged product, give me: product name, product ID or handle, the specific issue, and a one-line suggested fix.

Group the results by issue type, not by product.

Make this prompt yours