Back to cookbook

AI Prompt to Find and Remove Duplicate Records in a Dataset

12 views Published

Make this prompt yours

Share

This AI prompt helps you find and remove duplicate records in a dataset, including near-duplicates that differ only in casing, spacing, abbreviations, or formatting. It's built for analysts, operations staff, and anyone cleaning customer lists, transaction logs, or survey exports in ChatGPT, Claude, or Gemini before the data goes into a report or a database.

Most spreadsheet dedupe tools only catch exact matches on a single column, which misses the messier real-world cases: "Jon Smith" vs "Jonathan Smith," a phone number with and without dashes, or the same order entered twice with a typo in the email field. This prompt asks the model to reason about which fields should match exactly, which should be compared loosely, and how confident it is in each proposed match, so you get a reviewable list instead of a silent delete.

For very large files that exceed what you can paste into a single prompt, pulling only the relevant rows first matters more than the matching logic itself — in that case, running the file through a tool like Context Extractor first can cut the dataset down to the columns and rows actually worth comparing.

Prompt template

Make this prompt yours

prompt-template
271 tokens
Role: You are a data quality analyst reviewing a dataset for duplicate records. Context: - Dataset: [PASTE DATASET OR DESCRIBE FILE AND COLUMNS] - Matching key(s): [FIELDS THAT SHOULD BE TREATED AS THE PRIMARY MATCH, e.g. EMAIL AND LAST NAME] - Secondary fields to consider for near-matches: [E.G. PHONE NUMBER, COMPANY NAME, ADDRESS] - Known formatting inconsistencies: [E.G. SOME ENTRIES HAVE EXTRA SPACES, MIXED CASE, ABBREVIATIONS] Task: 1. Identify rows that are exact duplicates on the matching key(s). 2. Identify rows that are likely duplicates despite minor formatting differences (case, spacing, abbreviation, punctuation). 3. For each duplicate group, recommend which row to keep based on: [RULE, e.g. MOST RECENT DATE, MOST COMPLETE RECORD]. Constraints: - Do not delete or merge any rows yourself — only recommend. - Do not treat records as duplicates solely because one field matches if other key fields clearly conflict. - Flag anything uncertain as "possible duplicate" rather than guessing. Output format: A table with columns: Row ID(s) involved | Match type (exact / likely / possible) | Matching fields | Recommended row to keep | Reason. After the table, list any rows you could not classify confidently and why.

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
263 tokens
Role: You are a data quality analyst reviewing a dataset for duplicate records. Context: - Dataset: 12 rows of customer signups exported from two marketing tools, columns are Row ID, Full Name, Email, Phone, Signup Date - Matching key(s): Email - Secondary fields to consider for near-matches: Full Name, Phone - Known formatting inconsistencies: some emails have trailing spaces, some phone numbers include dashes and others don't Row 1: Jon Smith, jon.smith@acme.com, 555-201-4432, 2026-01-03 Row 2: Jonathan Smith, jon.smith@acme.com , 5552014432, 2026-01-09 Row 3: Maria Lopez, maria.lopez@acme.com, 555-887-1120, 2026-01-04 Row 4: M. Lopez, maria.lopez@acme.com, 5558871120, 2026-01-15 Row 5: David Chen, d.chen@acme.com, 555-440-9981, 2026-01-05 Task: same as template above, keep the most recent signup date, output as a table.

When to use it

  • You're merging two customer or contact lists exported from different systems
  • A spreadsheet has repeated rows from double form submissions or a failed import retry
  • You need to flag likely duplicates for human review rather than auto-deleting anything
  • You're preparing data for a CRM, mailing list, or database load where duplicates would cause errors

Best practices

  • Tell the model exactly which fields count as the matching key (e.g. email + last name) instead of letting it guess
  • Ask for a confidence label (exact, likely, possible) on each match instead of a flat duplicate/not-duplicate call
  • Request the row numbers or IDs being compared, not just the cleaned output, so you can audit the decision
  • Run smaller batches when the dataset is large — long lists increase the chance the model skips rows silently

Common mistakes

  • Asking the model to just "remove duplicates" without defining which columns must match
  • Letting the model delete rows outright instead of returning a review list you approve first
  • Ignoring formatting differences (extra spaces, inconsistent capitalization, date formats) that hide true duplicates
  • Pasting a dataset too large for the context window and getting incomplete or truncated results

FAQs

How do I prompt ChatGPT to find duplicate rows in a spreadsheet?

Give it the exact column(s) that should count as a match, describe any known formatting issues like extra spaces or inconsistent casing, and ask it to return a table of matches with a confidence level and a recommended row to keep, rather than deleting anything automatically.

Can AI catch near-duplicates that aren't an exact text match?

Yes, if you tell it which secondary fields to check and what kind of variation to expect, such as abbreviated names, missing punctuation, or inconsistent phone number formatting. Without that guidance, most models default to exact-match comparison only.

Why shouldn't I let the model auto-delete duplicate rows?

Because duplicate detection on messy real-world data is probabilistic, not certain. A model can misjudge two similar-looking but genuinely different customers as duplicates, so a reviewable list with reasons is safer than an irreversible delete.

What's the best way to handle a dataset too large to paste into one prompt?

Split it into smaller batches by row range, or extract only the columns relevant to matching before sending it to the model, since very long inputs increase the chance that rows get skipped or summarized instead of individually compared.

Which Cuelara tool can help me prepare a large dataset before running this prompt?

Context Extractor — pulls only the relevant rows and columns out of a large CSV or spreadsheet first, so the deduplication prompt works on a manageable, focused slice instead of truncating. Pair it with Intelligence Score to check whether your matching instructions are specific enough before you run them on the full dataset.

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