Power Query Problems

How to Automate CSV File Transformations with Power Query in Excel

Olivia MillerOlivia Miller Oct 26, 2026 868 views

Question details

The user needs to automate the removal of extra columns and clean up CSV exports so the transformation can be reused for future files before importing them into an accounting program.

How to Automate CSV File Transformations with Power Query in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
Preparing and cleaning recurring CSV exports for an accounting system.
Observed behavior
The user wants to save a specific sequence of data cleaning transformations and apply them automatically to new CSV exports without having to recreate the process each time.
Before you start

Ensure that your future CSV exports will maintain the exact same column structure and header names as the original file, as Power Query relies on these to apply your saved transformations correctly.

Solution 1Recommended

Build a Reusable Power Query by Overwriting the Source File

Create the transformation steps once on a base CSV file, and simply replace that file with new data in the future.

The easiest way to reuse a query is to keep the file path and file name of your source data constant. By replacing the old CSV file with the newly exported CSV file, Power Query can execute all recorded steps on the fresh dataset instantly.

1
Import the initial CSV

In Excel, navigate to the Data tab, click 'Get Data', choose 'From File', and then 'From Text/CSV'. Select your initial CSV export and click 'Transform Data'.

2
Apply your transformations

In the Power Query Editor, remove the unwanted extra columns, change data types for your accounting import, and click 'Close & Load' to save the query into your workbook.

3
Overwrite with future files

When you receive a new CSV export, rename it to exactly match the original file's name. Move it into the same folder, overwriting the old file.

4
Refresh the query

Open your Excel workbook containing the saved query, go to the Data tab, and click 'Refresh All'. The new CSV data will automatically be transformed according to your saved steps.

Build a Reusable Power Query by Overwriting the Source File
Workflow Tip: You can save your main Excel workbook anywhere. Only the source CSV file needs to maintain a static folder location and file name.
Free Microsoft Office alternative

Looking for a Lightweight Alternative for Data Processing?

If you find Microsoft Excel's Power Query too complex or simply need an accessible, affordable tool for daily data management, consider WPS Office. It provides a highly compatible spreadsheet tool that makes handling CSV files, organizing data, and performing daily calculations completely free and intuitive.

  1. 1. Download and Install: Get WPS Office for free from the official website and install it on your device in minutes.
  2. 2. Open your CSV Files: Launch WPS Spreadsheets and open your CSV exports directly with perfect layout retention.
  3. 3. Process and Save: Use built-in data tools to clean your spreadsheets and save them in widely accepted formats like .xlsx.
Seamless compatibility with Microsoft Excel formats (.xlsx, .csv, .xls).Intuitive Text-to-Columns and data filtering for easy CSV management.Lightweight software that runs smoothly on Windows, Mac, and Linux.Free to use for daily spreadsheet processing and accounting data preparation.
microsoft office alternative - wps office

Frequently Asked Questions

Can I apply my Power Query transformation to a CSV file with a different name?

Yes, but you must manually update the source. Open the Power Query Editor, click on 'Data Source Settings', select 'Change Source', and browse for the newly named CSV file. To avoid this step, it is easier to overwrite the original file with the new data using the same name.

Why does my query fail when I refresh with new CSV data?

Errors usually occur if the new CSV file has different column headers, a different delimiter, or missing columns compared to the original file used to build the query. Power Query expects a consistent data structure.

Can I copy my Power Query steps to another Excel workbook?

Yes. Open the Power Query Editor, go to the Home tab, and click 'Advanced Editor'. Copy the entire M code text, open a blank query in your new workbook, and paste the code there.