normalize.js script applies corrections automatically to ensure consistent, accurate airline data.
Why Corrections Are Needed
The OpenFlights project is community-maintained and follows its own conventions. This package applies corrections for:- Country name standardization - Converting formal names to commonly-used names
- Data corruption fixes - Correcting fields where data leaked between columns
- Duplicate resolution - Marking defunct airlines that share codes with active ones
- Code accuracy - Fixing incorrect IATA/ICAO codes in upstream data
All corrections are applied transparently via
normalize.js after fetching upstream data. The original upstream data is never modified directly.Country Name Corrections
TheCOUNTRY_CORRECTIONS map standardizes country names from formal/official names to commonly-recognized names:
View Full COUNTRY_CORRECTIONS Map
View Full COUNTRY_CORRECTIONS Map
normalize.js:14-28
How It Works
During normalization, each airline’s country field is checked against the correction map:normalize.js:102-106
Adding Country Corrections
To add a new country name correction:Per-Airline ID Corrections
TheID_CORRECTIONS map applies field-level corrections to specific airlines by their OpenFlights ID. This fixes:
- Field corruption (data leaked between columns)
- Incorrect active status
- Wrong IATA/ICAO codes
- Duplicate entries that cause code collisions
Structure
name, alias, iata, icao, callsign, country, active
Example Corrections
Data Corruption Fixes
Data Corruption Fixes
Some airlines have callsigns that leaked into the country field:
normalize.js:34-37
Duplicate/Defunct Airlines
Duplicate/Defunct Airlines
Airlines incorrectly marked active that share codes with current airlines:
normalize.js:38-44
IATA Code Collisions
IATA Code Collisions
Defunct airlines sharing codes with active ones (prevents lookup conflicts):
normalize.js:45-51
Incorrect IATA Codes
Incorrect IATA Codes
Wrong codes in upstream data:
normalize.js:79-82
How It Works
ID corrections are applied after country corrections:normalize.js:108-116
Adding ID Corrections
Identify the Issue
Find the airline ID that needs correction. You can search
airlines.json or airlines.dat by name or code.Edit normalize.js
Open
normalize.js and locate the ID_CORRECTIONS object around line 33. Add your correction:Always include a comment explaining the correction. This helps future maintainers understand why the fix was applied.
Other Data Quality Fixes
Beyond the correction maps,normalize.js also applies general data cleaning:
Callsign Whitespace Trimming
Some upstream records have leading spaces in the callsign field:normalize.js:97-100
Tracking Corrections
The normalize script reports how many rows were modified:Best Practices
Document Everything
Always add comments explaining why a correction is needed. Include dates and reasons.
Test First
Before committing corrections, test them locally to ensure they work as expected.
Upstream First
Consider submitting fixes to OpenFlights first. Use local corrections only when upstream changes aren’t feasible.
Version Control
Commit normalize.js changes separately from data updates for clarity in git history.
Correction Priority
Corrections are applied in this order:- Callsign whitespace trimming
- Country name corrections (via
COUNTRY_CORRECTIONS) - Per-airline ID corrections (via
ID_CORRECTIONS)