Find and merge duplicate rows in a sheet

Exact and near-duplicate rows grouped and merged into one row each, with a list of every merge.

  • You start it: When you start it

What it does

The task

Open the sheet sheet url. Find the rows that are the same entity, also when they are written differently, such as Ltd and Limited, missing accents, or www in one website and not in the other. Compare these columns: match columns. Copy the data to a new tab named Deduped, with one row for each group, and keep the most complete and most recent value in each column. Add a tab named Merges with each group, its original row numbers and the reason for the match. Do not delete anything in the original tab.

  • It works in Google Sheets, in the workspace you pick, and signs in with passwords from your Cuiar vault.
  • It runs once, when you start it.

What you give it

BlankWhat to giveExample
sheet urlThe Google Sheet with duplicateshttps://docs.google.com/spreadsheets/d/1Dd9wPz3Lc/edit
entityWhat one row iscompany
match columnsThe columns to compare, separated by commasCompany name, Website, Postcode

What you get back

An example run with the example values above. Your run uses your own data.

Rows read: 4,812. Duplicate groups: 389. Rows after the merge: 4,298

Match reasons:

  • Same website: 241 groups
  • Same name after Ltd, Limited and GmbH are removed: 96 groups
  • Similar name and same postcode: 52 groups

Example: rows 18, 2,203 and 3,977, 'Hollis Water Ltd', 'Hollis Water Limited' and 'HOLLIS WATER', merged as Hollis Water Ltd

Tabs: Deduped (4,298 rows), Merges (389 groups)

Check by hand: 14 groups with different phone numbers

Run it in Cuiar

  1. 01

    Open it

    Click Use in Cuiar on this page. The side panel opens with the task in the composer.

  2. 02

    Fill in 3 blanks

    Type sheet url, entity and match columns. Tab moves to the next blank.

  3. 03

    Run it

    Run sends it to the agent. Follow each step in the panel, and stop it at any time.

From the terminal

cuiar exec "Open the sheet https://docs.google.com/spreadsheets/d/1Dd9wPz3Lc/edit. Find the rows that are the same company, also when they are written differently, such as Ltd and Limited, missing accents, or www in one website and not in the other. Compare these columns: Company name, Website, Postcode. Copy the data to a new tab named Deduped, with one row for each group, and keep the most complete and most recent value in each column. Add a tab named Merges with each group, its original row numbers and the reason for the match. Do not delete anything in the original tab."

Run it from your AI agent

Claude Code, Codex, Cursor and other MCP clients reach Cuiar at https://mcp.cuiar.com/mcp. Add the server one time, then ask for the task in plain words, or call run_task yourself.

1. Add Cuiar to Claude Code

claude mcp add --transport http cuiar https://mcp.cuiar.com/mcp

2. Ask your agent

Use the Cuiar tool run_task to run my "Find and merge duplicate rows in a sheet" template with sheet url = https://docs.google.com/spreadsheets/d/1Dd9wPz3Lc/edit; entity = company; match columns = Company name, Website, Postcode.

Setup for other agents: AI agents.

The tool call

{
  "name": "run_task",
  "arguments": {
    "task": "Open the sheet https://docs.google.com/spreadsheets/d/1Dd9wPz3Lc/edit. Find the rows that are the same company, also when they are written differently, such as Ltd and Limited, missing accents, or www in one website and not in the other. Compare these columns: Company name, Website, Postcode. Copy the data to a new tab named Deduped, with one row for each group, and keep the most complete and most recent value in each column. Add a tab named Merges with each group, its original row numbers and the reason for the match. Do not delete anything in the original tab."
  }
}
All data templates
  • Data

    Turn a list on a website into a sheet

    Each item from each page, one row for each, with no duplicates.

    You start it: When you start it
    • Any website
    • Google Sheets
  • Data

    List local businesses with their contacts

    Name, address, phone, website, rating and e-mail for each business.

    You start it: When you start it
    • Google Maps
    • Google Sheets
  • Data

    Export your order history

    For stores with no export: each order in a sheet, with totals for each year.

    You start it: When you start it
    • Any online store
    • Google Sheets
  • Data

    Pull tables from PDFs into a spreadsheet

    Each matching table from your PDFs and scans in one sheet, with numbers as numbers and the page noted.

    You start it: When you start it
    • Google Drive
    • Google Sheets
  • Data

    Clean up a messy spreadsheet

    Consistent names, dates, phone numbers and amounts in a new tab, with a count of each type of change.

    You start it: When you start it
    • Google Sheets
  • Data

    Build one table from several public statistics

    Numbers from official sources in one sheet, with the same units, years and country codes.

    You start it: When you start it
    • Our World in Data
    • Any government site
    • Google Sheets