Skip to content

How to clean a CSV file offline, without uploading it

How to clean an export full of customer data without sending it to a website, and without letting Excel rewrite your IDs and dates.

We make CSV Cleaner, the app this guide uses. The free methods come first; every step shown in CSV Cleaner was checked in the app itself, and the screenshots come from the real app with invented sample data.

Short answer

Do not double-click the CSV first. Excel changes some values the moment it opens a file: leading zeros disappear, numbers longer than 15 digits lose their last digits, and some codes become dates. List the risky cells, clean the file on your own PC, keep the original untouched, and give people an .xlsx (or an import with those columns set to text) instead of the raw CSV.

Why opening a CSV in Excel is the risky step

A CSV file is plain text. RFC 4180 describes the format: rows, separators, and quotes around fields that contain a comma, a quote or a line break. It says nothing about types, so every value is text until a program decides otherwise. Excel decides as it opens the file. Microsoft's page Keeping leading zeros and large numbers lists what it changes:

In the CSV What Excel does with it Typical column
02134 Removes the leading zero: 2134 Postal codes, product codes
400000000000123456 Keeps 15 significant digits; the digits after the 15th become zeros Order, account and card numbers
1E5 Reads digits around the letter E as scientific notation SKUs, lot codes
MARCH1 Turns a run of letters and numbers into a date SKUs, part numbers

If you then save, the file holds the changed values, and Microsoft notes that formatting a column afterwards does not bring removed zeros back. Excel for Microsoft 365 and Excel 2024 have a setting to switch these automatic conversions off (the same Microsoft page); older versions do not.

A second risk is a cell that starts with =, +, - or @. The OWASP page on CSV injection explains that spreadsheet programs may read such a cell as a formula, which matters when an export contains text typed by customers.

Method 1 (free): list the risky cells with PowerShell first

Windows PowerShell 5.1 comes with Windows 10 and 11. Its Import-Csv reads every value as text and changes nothing, so it can show you the cells Excel would change before anyone opens the file. Change the path on the first line; for a file separated by semicolons, add -Delimiter ';' after -Encoding UTF8.

$file = "$env:USERPROFILE\Documents\orders-2026-10.csv"
$rows = Import-Csv -LiteralPath $file -Encoding UTF8
$line = 1
$report = foreach ($row in $rows) {
  $line++
  foreach ($cell in $row.PSObject.Properties) {
    $v = [string]$cell.Value
    $why = $null
    if ($v -match '^0\d+$') { $why = 'leading zero would be dropped' }
    elseif ($v -match '^\d{16,}$') { $why = 'over 15 digits: the end would become zeros' }
    elseif ($v -match '^\d+(\.\d+)?E[+-]?\d+$') { $why = 'digits around E: read as scientific notation' }
    elseif ($v -match '^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[a-z]*\d{1,2}$') { $why = 'letters then a number: may become a date' }
    elseif ($v -match '^[=+\-@]') { $why = 'starts like a formula' }
    if ($why) { [pscustomobject]@{ Row = $line; Column = $cell.Name; Value = $v; Why = $why } }
  }
}
$report | Format-Table -AutoSize

On a sample export with invented data (tested on 30 November 2026 in Windows PowerShell 5.1), it printed, among others:

Row Column   Value              Why
--- ------   -----              ---
  2 order_id 400000000000123456 over 15 digits: the end would become zeros
  2 phone    +16175550123       starts like a formula
  2 zip      02134              leading zero would be dropped
  2 sku      MARCH1             letters then a number: may become a date
  3 note     @home delivery     starts like a formula
  4 sku      1E5                digits around E: read as scientific notation

Row 2 is the first row of data (the header is row 1), so the numbers match a spreadsheet's rows as long as no value spans several lines. The script only reads: it is a check, not a cleaner, and it looks for these five patterns only.

Method 2 (free): import the columns as text in Excel

When the file has to go into Excel, import it instead of opening it. Microsoft documents the steps in Keeping leading zeros and large numbers and Import or export text (.txt or .csv) files:

  1. On the Data tab, choose From Text/CSV and pick the file.
  2. In the preview, choose Edit to load the Query Editor.
  3. Select the columns that hold codes (postal codes, order numbers, SKUs), then Home > Transform > Data Type > Text, and Replace current.
  4. Choose Close & Load. When the file changes, Data > Refresh loads it again with the same steps.

These are Microsoft's steps; Excel is not installed on the PC used for this guide, so we did not run them. Spaces, letter case, duplicates and date formats still need cleaning after the import.

Method 3 (free): OpenRefine for larger clean-ups

OpenRefine is a free, open-source tool for cleaning data. Its manual explains that it runs as a small web server on your own computer that you use through your browser, so the data stays on your machine. It needs a separate install and some learning, and it was not part of our tests: we cite it from its documentation.

Method 4: CSV Cleaner, when the same export comes back every month

CSV Cleaner is our Windows app for this job. It opens .csv, .tsv and .txt exports, profiles every column and names the cells Excel would change before anything is saved. It runs offline; the screenshots below come from version 1.0.0 with invented data.

  1. Open the export. The encoding and the separator are detected. Phone numbers written without a + get the country you choose.
  2. Read the profile. Each column shows what it holds and what is wrong with it; the Excel would change tab lists the cells at risk.
  3. Choose the steps. The suggested steps (garbled characters, spaces, dates, phone numbers, e-mail addresses, duplicates, empty rows and columns, keeping and renaming columns) can each be switched off or reordered. A date column gets one date order, decided once for the column, never guessed cell by cell.
  4. Check every change. Each step lists the cells it changes, before and after. A value it cannot fix is kept as it was and listed.
  5. Save a new file. A CSV or an .xlsx, with a change log CSV next to it. The original is only read.
CSV Cleaner with an orders export open: the Excel would change tab lists 31 cells, such as 00123 becoming 123 and an 18-digit order number cut to 15 digits, next to the suggested cleaning steps.
The profile of a sample orders export: 31 cells Excel would change, and the suggested steps. CSV Cleaner 1.0.0, captured on 27 November 2026, invented data.
The Changes tab for the phone number step: each cell before and after, and one number kept unchanged because it is not a valid number in the chosen country.
Every change of one step, before and after; a number that is not valid is kept and listed, not guessed. CSV Cleaner 1.0.0, captured on 27 November 2026.
The result after nine steps, saved as an .xlsx file of 8 rows and 9 columns with a change log of 38 entries, the original file unchanged.
Saved as .xlsx with a change log of 38 entries; the original CSV is not changed. CSV Cleaner 1.0.0, captured on 27 November 2026.

The steps can be saved as a recipe and run on next month's export or on a folder of exports. A file that does not fit the recipe is stopped before anything is written.

How to Stop Excel from Changing Your CSV (Leading Zeros, Dates)1:07Watch on YouTubeNothing loads from YouTube until you press play. The player then loads from youtube-nocookie.com, YouTube's privacy-enhanced mode, and connects to Google's servers. Privacy

Check the result

  • Compare the row counts before and after. If duplicates were removed, the change log says which rows went.
  • Read a sample of the change log, and look at the columns Method 1 flagged: postal codes, order numbers, SKUs.
  • Remember that a cleaned CSV is still a CSV: Excel will still drop the zero of 02134 when someone double-clicks it. If people will open the file in Excel, hand them the .xlsx, in which every cell keeps the value as written.

Limitations

  • The PowerShell check reads UTF-8 files and looks for five patterns. Excel's guessing is broader than any short script, so treat an empty report as a good sign, not as proof.
  • No tool can restore digits Excel has already cut: if the file you received was saved by Excel, go back to the original export.
  • CSV Cleaner runs on Windows 10 (22H2) or 11, 64-bit, with 4 GB of RAM, or 8 GB for files near its 100 MB limit. It reads .csv, .tsv and .txt files, not .xlsx. It does not merge several files into one, and it removes exact duplicates (ignoring case and spaces), not similar-looking names. Its interface is in English.

References