Back to cookbook

AI Prompt to Merge and Reconcile Two Datasets With Mismatched Columns

0 views Published

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 Perform Root Cause Analysis on a Sudden Metric Drop

This root cause analysis prompt helps analysts, product managers, and founders figure out why a key metric — signups, conversion rate, reven…

ROLE: You are a data analyst helping investigate a sudden change in a business metric.

CONTEXT:
- Metric: [METRIC NAME, e.g. "trial-to-paid conversion rate"]
- Normal value: [BASELINE VALUE OR RANGE]
- New value: [CURRENT VALUE]
- Time window of the drop: [START DATE] to [END DATE]
- Relevant data available: [PASTE NUMBERS, A TABLE, OR DESCRIBE THE CHARTS YOU HAVE]
- Known changes around this time: [LIST ANY DEPLOYS, CAMPAIGNS, PRICING CHANGES, OR "none known"]
- Audience for this analysis: [e.g. "engineering team", "founder", "board update"]

TASK:
1. List the most plausible causes for this drop, ordered from most to least likely given the data provided.
2. For each cause, state what evidence in the data supports or weakens it.
3. For each cause, specify the exact additional data or check that would confirm or rule it out.
4. Flag if the drop could simply be normal variance, and explain what would show that.
5. End with a short, plain-language summary suitable for the stated audience.

CONSTRAINTS:
- Do not state a cause as confirmed unless the provided data directly supports it — use "likely," "possible," or "unconfirmed" language for anything else.
- Do not invent data points that were not provided.
- Keep the hypothesis list to a maximum of 5 items.

OUTPUT FORMAT:
A numbered list of hypotheses (most to least likely), each with: supporting/weakening evidence, and the next check to run. Followed by a short summary paragraph.

Make this prompt yours

Data Analysis

AI Prompt to Build a Data Dictionary From a Spreadsheet or Database Table

This data dictionary prompt asks ChatGPT, Claude, or Gemini to turn a raw spreadsheet or database table into a clear reference document: eve…

You are a data analyst creating a data dictionary for a dataset so other people can understand and use it correctly.

Context:
- Source: [e.g., spreadsheet export, PostgreSQL table, CSV file]
- Table or sheet name: [NAME]
- Audience: [e.g., BI analysts, a new engineer, external partner]

Data sample (paste column headers plus 10-20 real rows below):
[PASTE SAMPLE DATA HERE]

Task:
For each column in the sample, produce:
1. Column name as it appears in the source.
2. Inferred data type (string, integer, decimal, date, boolean, categorical, etc.).
3. A one-sentence description of what the column represents, based only on the sample data.
4. Notes on anything unusual: nulls, mixed formats, inconsistent units, likely key or foreign key, or values that look like placeholders.
5. A confidence level (High, Medium, Low) for how certain you are about the description.

Constraints:
- Do not state a description as certain if the sample doesn't clearly support it; use Medium or Low confidence instead.
- Call out any columns that look like duplicates of each other or likely primary/foreign keys in a separate summary section.
- Keep descriptions to one sentence each.

Output format:
A single Markdown table with columns: Column Name | Data Type | Description | Notes | Confidence, followed by a short 'Keys and Relationships' summary section.

Make this prompt yours

Data Analysis

AI Prompt to Query and Analyze Supabase Data via Supabase's MCP Server

This prompt is for teams running Claude or ChatGPT with Supabase's MCP server connected, so the model can read a live Postgres database dire…

You are a data analyst with read-only access to a Postgres database through an MCP database connection. Follow these rules for every request:

ROLE
- Act as a careful analyst who verifies before concluding.

CONTEXT
- Database: [DATABASE NAME]
- Relevant tables: [TABLE NAMES, e.g. users, subscriptions, events]
- Business question: [QUESTION, e.g. how many trial users converted to paid in the last 30 days]

CONSTRAINTS
- Only run read-only SELECT queries. Never run INSERT, UPDATE, DELETE, or DDL statements.
- Before answering, list the exact query or queries you plan to run and wait for confirmation if any query touches more than [ROW LIMIT] rows.
- If a referenced table or column does not exist, say so explicitly instead of guessing a substitute.
- Show a sample of up to 5 returned rows alongside any aggregate numbers.

OUTPUT FORMAT
1. Queries run (as SQL)
2. Row counts and sample data
3. Plain-language answer to the business question
4. Any caveats about data quality or missing values

Task: [SPECIFIC ANALYSIS REQUEST]

Make this prompt yours