Python · Excel · Automation

Consolidated Cost Processing Script

A Python script that collects cost data from dozens of Excel files, consolidates it into a single template workbook and builds a pivot table by carrier — replacing a weekly manual consolidation.

Sector
Logistics · Finance
Type
Reporting automation
Related service

The challenge

Shipping cost data arrived as many separate Excel files spread across folders. Every week someone had to open them one by one, copy the relevant sheet into a master file, tidy it up and rebuild the pivot table by hand — slow and error-prone.

The solution

A single script that runs the whole consolidation end to end:

CollectFinds every .xlsx file in a folder and its subfolders
Extract & cleanReads the target sheet, removes empty rows, rounds values
ConsolidateAppends each file to the template at the next free row
SummariseBuilds a pivot of costs and totals by carrier, sorted by total
Python loop that reads each Excel file and extracts the target sheet
File processing: one loop, every workbook
Python code building a pivot table of shipping costs by carrier
Pivot by carrier, rounded and sorted

Results

  • Weekly manual consolidation eliminated
  • Pivot table ready to use as soon as the script finishes
  • Any number of files handled in a single run
  • Errors caught and logged, with execution time reported

Stack

Python Pandas openpyxl Excel

Client names and confidential figures have been omitted. The images on this page contain no client data.

Other projects

Still copying and pasting between spreadsheets?

Send me a description of your Excel routine and I'll tell you how much of it can run on its own — no commitment required.

Get in touch All projects