New Tool Radar

AI for Data & Spreadsheets

How to Clean a CSV Import in Excel with Power Query

Clean a messy CSV import in Excel with Power Query so blank rows, wrong types and stray spaces never reach your sheet.

Schematic illustration for How to Clean a CSV Import in Excel with Power Query: three numbered steps - Get Data, From Text/CSV; Remove blanks, fix types; Close and Load.

A CSV opened directly in Excel often lands with blank rows, numbers stored as text and dates in the wrong order. Power Query treats the import as a repeatable set of steps, so the same cleaning runs again next month when the file is refreshed instead of being redone by hand.

Prerequisites

  • Excel for Microsoft 365 or Excel 2016 or later on Windows
  • The CSV file
  • A copy of the source file, so the original stays untouched.

Steps

  1. In Excel, go to Data, Get Data, From File, From Text/CSV and select the CSV file.
  2. In the preview, check the delimiter and encoding, then click Transform Data to open the Power Query Editor.
  3. Remove blank rows with Home, Remove Rows, Remove Blank Rows, and trim spaces with Transform, Format, Trim.
  4. Set each column to its correct type, such as Decimal Number for amounts and Date for dates, and fix any errors the type change creates.
  5. Click Close and Load, then check the loaded table against the CSV before using it.

Worked example: Fictional membership CSV import

The practice table below is a fictional five-member import after cleaning. The fee column is the annual fee per member, and the total is their sum. The table below is fictional practice material, with fictional values. It is the expected result, worked out by hand, not a run of any tool.

Member Joined Fee
Amara Okafor 2026-01-15 25.00
Ben Whitfield 2026-02-03 25.00
Clara Jensen 2026-02-20 30.00
Dev Patel 2026-03-01 25.00
Elena Rossi 2026-03-12 30.00
Total 135.00

Expected result. Five members loaded, no blank rows, all fees are numbers, and the fees add to 135.00.

Limits

  • Power Query leaves the source file unchanged, so a mistake in the CSV must be fixed in the source, not the query.
  • A CSV with inconsistent delimiters may need its separator set by hand in the preview.

Sources

See all