top of page

How to fuzzy match and join two datasets with ChatGPT and verify matches

1 minute ago
9 min read
Cover showing the title How to fuzzy match and join two datasets with ChatGPT and verify matches over a teal city skyline, Data Studios original cover

Joining two tables that describe the same customers with different spellings is one of the most common chores in analytics work. A CRM export lists "Acme Corporation", the billing system lists "ACME Corp.", and an exact join on the name column silently drops the invoice. ChatGPT's data analysis feature can handle this task because, according to OpenAI's help documentation, it writes and runs Python with pandas on the files you upload and then reports the results back in the conversation.


The method that works is a short, auditable pipeline: normalize the names, score each candidate pair with a string-similarity measure, accept only matches that are both strong and clearly ahead of the runner-up, and send everything else to a review list. The worked example below joins eight invoices to six CRM accounts. An exact join on the raw names finds only 2 of the 8 invoices, worth $2,940.00 of the $8,210.75 total. The normalized fuzzy match links 7 invoices worth $7,910.75 and correctly leaves one unknown customer, worth $300.00, unmatched.


The rest of the procedure is about making the AI's output checkable: the prompts to use, the expected result computed independently in Python, and the controls that catch a wrong match before it reaches a report.


··········


WHEN ANALYSTS NEED A FUZZY JOIN IN CHATGPT.


A fuzzy join is needed whenever two sources share an entity but no reliable common key. Typical cases are a CRM account list matched against invoices or payments, a vendor master matched against purchase card transactions, survey respondents matched against a customer list by company name, and two product catalogs merged after a system migration. The differences are usually mechanical: capitalization, punctuation, legal suffixes such as Inc., LLC or Corporation, an ampersand written as "and", a missing space, or a dropped final letter.


These mechanical differences are the part a script handles well. The difficult part is the small number of names that look alike but belong to different entities, such as two companies that share a brand word. A matching rule that is too loose merges them, and the error is hard to spot once the joined table has been aggregated. For that reason the output of a fuzzy join is a proposal that has to be reviewed, and the review list is as important as the matched table.


If the data first needs cleaning inside a single file, the earlier walkthrough on how to clean and deduplicate a CSV with ChatGPT and verify the counts covers that step. The procedure here starts from two reasonably clean files whose keys disagree.


··········


CHATGPT DATA ANALYSIS REQUIREMENTS AND FILE LIMITS FOR MATCHING.


The figures below come from OpenAI's help center articles on data analysis and on file uploads, verified on November 18, 2026. The data analysis article does not state which ChatGPT plans include the feature, so check the plan page for your account before relying on it in a team workflow.


........


Item

What OpenAI documents

Supported data files

Excel (.xls, .xlsx), CSV, PDF, JSON

Files per conversation

Up to 10

Size per file

512MB hard limit

CSV and spreadsheets

About 50MB, depending on row size

Free plan uploads

3 files per day

How analysis runs

Python with pandas, Matplotlib for charts

Environment lifetime

Destroyed within 13 hours of inactivity

Network access

No direct outbound requests


........


Two of these limits shape a matching task directly. Both tables must be uploaded to the same conversation, which the 10-file limit allows comfortably. And because the execution environment is destroyed within 13 hours of the conversation becoming inactive, the matched table and the review list should be downloaded at the end of the session rather than left in the chat. When one of the files is larger than the spreadsheet limit, the approach described in how to analyze a CSV over ChatGPT's 50MB limit with chunks and samples applies: reduce the large file to the key column and the fields you need before uploading.


OpenAI's documentation does not describe a dedicated fuzzy-matching function in ChatGPT. The task is done the way any other data analysis request is done, by asking ChatGPT to write and run Python code. The standard library module difflib, used in the reference code below, ships with Python itself, so the method does not depend on any extra package being installed.


··········


THE ILLUSTRATIVE DATASETS FOR THE FUZZY JOIN.


The two tables below are illustrative, built for this example. The first is a CRM account list with a clean account ID. The second is an invoice export where the customer name was typed by hand.


........


account_id

account_name

A-101

Acme Corporation

A-102

Bright Line LLC

A-103

Northwind Traders

A-104

Northwind Logistics

A-105

Delta Dental Group

A-106

Kessler & Sons Inc.


........


........


invoice_id

customer

amount_usd

INV-01

ACME Corp.

1200.00

INV-02

Brightline, L.L.C.

860.50

INV-03

Northwind Traders

2300.00

INV-04

Northwind Logistic

410.00

INV-05

Kessler and Sons

975.25

INV-06

Acme Corporation

640.00

INV-07

Delta Dental

1525.00

INV-08

Orion Freight

300.00


........


The set contains the usual traps. Two accounts share the word Northwind and must stay separate. One invoice name has lost a letter. One customer, Orion Freight, has no CRM account at all, and a careless matcher will attach it to whichever account scores highest.


··········


PROMPTS FOR THE FUZZY JOIN IN CHATGPT.


Upload both files to one conversation and ask for the profile before any matching, so that you can confirm the columns and row counts ChatGPT has read.


I uploaded two files: crm_accounts.csv and invoices.csv.
Before matching anything, report for each file: the row count, the column names,
the number of distinct values in account_name and in customer, and any blank names.
Do not modify the data yet.

Then ask for the matching with explicit rules, so the output can be compared with an independent result.


Match each invoice to at most one CRM account using the customer and account_name columns.
1. Normalize both names: lowercase, replace "&" with "and", remove punctuation,
   remove legal suffixes (inc, incorporated, corp, corporation, co, company, llc, ltd, limited, group),
   then remove all spaces.
2. Check that the normalized CRM names are unique and stop if they are not.
3. Score every invoice against every account with difflib.SequenceMatcher ratio on the normalized names.
4. Auto-match only if the best score is at least 0.90 AND it beats the second-best score by at least 0.15.
   Scores from 0.75 to 0.90 go to a review list. Below 0.75 is "no match".
5. Left-join the result to the invoices so every invoice appears exactly once.
Show a table with invoice_id, customer, matched account_id, best score, margin over second best and decision.
Then give the count and total amount_usd per decision, and confirm the joined row count equals the invoice row count.
Show the full Python code you ran.

Asking for the code is the most useful control in the whole procedure. It lets you check that the thresholds you asked for are the thresholds that were applied, and it lets you rerun the same logic outside the chat.


··········


EXPECTED RESULT OF THE FUZZY JOIN, COMPUTED IN PYTHON.


The following code was run on the illustrative data and produces the reference result. ChatGPT's code may look different, but its output on these two tables should match the table that follows it.


import re
import pandas as pd
from difflib import SequenceMatcher

crm = pd.DataFrame({
    "account_id": ["A-101", "A-102", "A-103", "A-104", "A-105", "A-106"],
    "account_name": ["Acme Corporation", "Bright Line LLC", "Northwind Traders",
                     "Northwind Logistics", "Delta Dental Group", "Kessler & Sons Inc."],
})
inv = pd.DataFrame({
    "invoice_id": [f"INV-0{i}" for i in range(1, 9)],
    "customer": ["ACME Corp.", "Brightline, L.L.C.", "Northwind Traders", "Northwind Logistic",
                 "Kessler and Sons", "Acme Corporation", "Delta Dental", "Orion Freight"],
    "amount_usd": [1200.00, 860.50, 2300.00, 410.00, 975.25, 640.00, 1525.00, 300.00],
})

SUFFIX = r"\b(incorporated|inc|corporation|corp|company|co|llc|ltd|limited|group)\b"

def norm(name):
    s = name.lower().replace("&", " and ")
    s = re.sub(r"[^\w\s]", " ", s)          # drop punctuation
    s = re.sub(r"\bl\s+l\s+c\b", "llc", s)  # "l l c" -> "llc"
    s = re.sub(SUFFIX, " ", s)              # drop legal suffixes
    return re.sub(r"\s+", "", s)            # drop all spaces

crm["key"] = crm["account_name"].map(norm)
assert crm["key"].is_unique, "two CRM accounts share a key: review before joining"

def best_two(key):
    scored = sorted(((SequenceMatcher(None, key, k).ratio(), i) for i, k in crm["key"].items()), reverse=True)
    return scored[0], scored[1]

rows = []
for _, r in inv.iterrows():
    (s1, i1), (s2, _) = best_two(norm(r["customer"]))
    if s1 >= 0.90 and s1 - s2 >= 0.15:
        decision = "auto-match"
    elif s1 >= 0.75:
        decision = "review"
    else:
        decision = "no match"
    rows.append({"invoice_id": r["invoice_id"], "account_id": crm.at[i1, "account_id"] if decision == "auto-match" else None,
                 "score": round(s1, 3), "margin": round(s1 - s2, 3), "decision": decision})

matches = pd.DataFrame(rows)
joined = inv.merge(matches, on="invoice_id", how="left")
assert len(joined) == len(inv), "the join changed the row count"
print(joined[["invoice_id", "customer", "account_id", "score", "margin", "decision"]].to_string(index=False))
print(joined.groupby("decision")["amount_usd"].agg(["count", "sum"]))

........


invoice_id

customer

account_id

score

margin

decision

INV-01

ACME Corp.

A-101

1.000

0.733

auto-match

INV-02

Brightline, L.L.C.

A-102

1.000

0.615

auto-match

INV-03

Northwind Traders

A-103

1.000

0.353

auto-match

INV-04

Northwind Logistic

A-104

0.971

0.365

auto-match

INV-05

Kessler and Sons

A-106

1.000

0.680

auto-match

INV-06

Acme Corporation

A-101

1.000

0.733

auto-match

INV-07

Delta Dental

A-105

1.000

0.630

auto-match

INV-08

Orion Freight

none

0.455

0.026

no match


........


The decision totals give the reconciliation figures to check against ChatGPT's answer: 7 auto-matched invoices for $7,910.75 and 1 unmatched invoice for $300.00, which add back to the $8,210.75 invoice total. Acme Corporation receives two invoices for a combined $1,840.00, and every CRM account ends up with at least one invoice.


........


Check

Expected value

Invoices in, rows out

8 and 8

Exact join on raw names

2 invoices, $2,940.00

Auto-matched after normalization

7 invoices, $7,910.75

Unmatched

1 invoice, $300.00

Matched plus unmatched

$8,210.75


........


Normalization does most of the work. Scored on lowercase raw names without the cleanup step, "ACME Corp." reaches only 0.692 against "Acme Corporation" and "Kessler and Sons" reaches 0.743 against "Kessler & Sons Inc.", so both would fall below the auto-match threshold. After normalization both score 1.000.


··········


WHAT CHATGPT TENDS TO GET WRONG IN A FUZZY JOIN.


The first risk is a forced match. If the code simply takes the highest score for every row, Orion Freight is attached to an existing account even though its best score is 0.455 and the runner-up is only 0.026 behind. A low score with a thin margin means the name is unknown, and the correct output is an empty account ID.


The second risk is an over-aggressive normalization. Removing too many words, for example every word that also appears in another account, can collapse Northwind Traders and Northwind Logistics into the same key. The uniqueness check on the normalized CRM names stops the run when that happens, so ask ChatGPT to keep that check in its code.


The third risk is a fan-out. If the CRM list contains duplicate names, a left join returns more rows than there were invoices and the revenue total is inflated. Comparing the row count before and after the join, and the amount total before and after, catches this immediately.


The fourth risk is a silent change in thresholds or rules between the prompt and the code. Read the thresholds in the code ChatGPT shows, rerun the code on a copy of the data if the result feeds a report, and compare its decision totals with the reconciliation table. The reasoning behind checking calculations instead of trusting the summary is the same one covered in whether ChatGPT can analyze CSV files and how it handles errors.


........


Control

What it catches

Normalized CRM keys unique

Two accounts collapsed into one

Score and margin thresholds

Forced matches of unknown names

Row count before and after join

Duplicate keys fanning out rows

Amount total before and after

Lost or double-counted revenue

Review list checked by a person

Look-alike names of different entities


........


Any row in the review band, and any auto-match between names that share a distinctive brand word, should be approved by a person who knows the customers. A matched table that feeds billing, commissions or revenue reporting should carry the score and the decision column, so the evidence for each link stays visible after the join.


··········


DATA HANDLING NOTES FOR MATCHING CUSTOMER FILES IN CHATGPT.


Customer and invoice lists usually contain personal or commercially sensitive data. OpenAI's data analysis documentation states that the execution environment is accessible only within the associated conversation, is isolated from the rest of the ChatGPT platform and cannot make outbound network requests directly. The file uploads FAQ states that uploaded files are kept until the chat's retention period ends and are deleted within 30 days after the chat or account is deleted, with exceptions.


On training, OpenAI's help article on model improvement states that content from ChatGPT Team, ChatGPT Enterprise and the API Platform is not used for training by default, while individual users can opt out through OpenAI's privacy portal or the Data Controls settings. For matching tasks, uploading only the key column, the ID and the fields needed for the check reduces the amount of sensitive data in the conversation without weakening the method.


··········


FUZZY JOINS IN CHATGPT: WHAT THE RESULT DEPENDS ON.


OpenAI documents the mechanics that make the task possible: up to 10 uploaded files per conversation, Python and pandas in an isolated environment, spreadsheet files of roughly 50MB, and an environment that disappears within 13 hours of inactivity. It does not document a built-in fuzzy-matching feature, so the quality of the join depends entirely on the code ChatGPT writes and on the rules you put in the prompt.


The rules that produced a clean result on the example are specific. Normalize names before scoring, require a high score and a clear margin over the second candidate, keep a review band, check that the normalized keys are unique, and reconcile row counts and amounts after the join. With those rules the illustrative join moved from 2 matched invoices to 7, while the one unknown customer stayed unmatched. Which accounts and plans have data analysis enabled, and what thresholds suit a real customer list with thousands of names, remain decisions for the account owner and the analyst, tested on a sample whose correct matches are known in advance.


··········


FOLLOW US FOR MORE.


·····


DATA STUDIOS


·····


datastudios.org


bottom of page