Blog

How to find and replace values in a large CSV

Find a value in a large CSV, check matching rows, edit the right cells, and save a clean copy without changing other data.

Sarah CollinsTools and utilities 4 min read

You need to change a value in a CSV file, but searching through thousands of rows by eye is slow and risky. A global change can also affect rows you meant to leave alone.

Use the CSV Editor to find matching values, inspect the rows, and edit the cells that should change. It can open CSV files up to 10 million rows. Make a copy of the original first so you can check your work or start over.

Find and replace values in a large CSV

  1. Open the CSV Editor and open your CSV file. Keep the original file unchanged, and work on a copy with a clear name such as orders-updated.csv.
  2. Find the column that contains the value you want to change. Use the editor's find feature to search for the old value. If the file has many columns with similar data, confirm the column heading before editing anything.
  3. Check the matching rows. Make sure each result is a value you intend to replace, not just a similar word in a different column or a longer value that happens to contain the same characters.
  4. Change the value in the intended cell or cells. If your current editor view offers a bulk replacement action, test it on a copy and review the matching rows before applying it. A search by itself does not change the CSV.
  5. Search for the old value again to check whether any intended matches remain. Then inspect several changed rows and save or export the edited file as a new CSV.

For a small number of matches, editing each cell after checking its row is straightforward. If there are thousands of matches, confirm that the editor can apply the same change to all intended results before you begin. Otherwise, changing cells one at a time may take too long and make mistakes harder to spot.

What the results mean

Every match is the value you want to change

You can replace all of those matches, but still check the column and a sample of rows before applying a bulk change. For example, changing Pending to Complete in an order-status column may be correct, while the same word in a notes column may not be.

Some matches should stay as they are

Do not use an unrestricted replace-all operation. Check the surrounding columns to tell which rows qualify, then edit only those cells. A matching value does not tell you whether the rest of the row meets your conditions.

The search finds no matches

The value may have extra spaces, different capitalization, or a different spelling. It may also be in a different column than you expected. Try a shorter, distinctive part of the value and inspect the results before making changes.

The search finds more matches than expected

Your search may be matching part of a longer value. Searching for cat, for example, could also find catalog. Review the full cell contents and use a more specific search when possible.

How to fix common problems

  1. Check the column before editing. A CSV can contain repeated headings or similar values in different fields. Use the row's other values to confirm you are changing the right kind of data.
  2. Search for a shorter part of the value. If an exact search returns nothing, remove punctuation or one part of the text. Check the results carefully, since a shorter search can find unrelated values too.
  3. Check spaces and capitalization. Values such as Active, active, and Active may not be treated as identical. Look at the full cell and decide which variations should change.
  4. Restore the original if the wrong rows changed. Close the edited copy without saving over your source, then open the untouched original and repeat the change more selectively. This is why keeping a separate copy matters.
  5. Check the saved file in the editor. Reopen the new CSV and confirm that the changed values are still present and the columns remain in place. For more guidance on saving edits, see how to correct a CSV and save the edited file.

Why a CSV can look different from a spreadsheet

A CSV stores rows of text separated by commas or another delimiter. It does not keep spreadsheet formatting, colors, or formulas. A value that looks like a number may be an identifier, and changing how it is interpreted can cause problems.

Take extra care with ZIP codes, product codes, and account numbers that start with zero. Spreadsheet programs sometimes remove those zeros when they open a CSV. Check the value in the editor before and after editing, and avoid treating an identifier as a number. Commas and quotation marks inside a value may also be handled with CSV quoting, so edit the cell in the editor rather than changing the raw file text by hand.

The CSV Editor works in your browser, and the file you open stays on your device.