This project demonstrates how to clean, validate and audit spreadsheet data using Google Apps Script.
It reads raw data from a Google Sheet, applies validation and cleaning rules, and exports valid records into a clean dataset while keeping an audit trail of discarded rows.
This type of automation is commonly used in data migration, data preparation and spreadsheet workflow automation.
- Data validation and cleaning
- Removal of incomplete records
- Automatic conversion of text-based numeric values
- Sales threshold filtering
- Logging of skipped rows
- Audit trail stored in
Cleaning_Log - UI confirmation popup
- Custom menu inside Google Sheets
- Google Apps Script
- JavaScript (ES6)
- Google Sheets
The script reads raw records from the Raw_Data sheet, validates and cleans the data, and writes the valid rows into Clean_Data.
Invalid or incomplete rows are logged into the Cleaning_Log sheet to keep an audit trail of discarded data.
Expected columns:
| Column | Description |
|---|---|
| Name | Customer or user name |
| Contact email | |
| Sales | Numeric sales value |
Example messy data the script can handle:
| Name | Sales | |
|---|---|---|
| Mario | mario@email.com | 150 |
| Luca | 200 | |
| Anna | anna@email.com | 80 |
| John | john@email.com | "150€" |
The script performs the following validations:
- Removes rows where Name or Email is missing
- Cleans numeric values from text (example:
"150€"→150) - Converts values to numbers
- Keeps only rows where Sales ≥ 100
- Logs discarded rows into the Cleaning_Log sheet
- Create a Google Sheet with the following tabs:
Raw_Data
Clean_Data
-
Open Extensions → Apps Script
-
Copy the script from:
src/cleaning.js
-
Save the project
-
Run
runCleaning()once to authorize the script -
Reload the spreadsheet
You will see a custom menu:
Data Tools → Run Data Cleaning
You can also trigger the script using a button:
- Insert → Drawing
- Create a button labeled Run Data Cleaning
- Click the drawing → Assign Script
- Enter:
runCleaning
google-sheets-data-cleaning-appsscript
│
├── src
│ └── cleaning.js
│
├── README.md
└── LICENSE
Possible extensions:
- Advanced validation rules
- Export logs to external datasets
- Email notification on cleaning completion
- Data quality reporting dashboard
MIT License
