Context Help: Comma-Separated Value (CSV) Format
This document defines Revision 0.41
of the comma-separated value (CSV) format natively exported and imported by OpenFlights.
OpenFlights CSV follows RFC 4180.
- The character set encoding is UTF-8.
- The field separator is comma (, 0x2C), the row separator is CRLF (\r\n 0x0D 0x0A) and the field delimiter is double quote (" 0x22).
- The first line of any OpenFlights CSV file is considered a
header and ignored. This line starts with a Unicode Byte
Order Mark (U+FEFF), represented in UTF-8 as 0xEF 0xBB 0xBF.
(Old OpenFlights exports incorrectly used the UTF-16 BOM 0xFE OxFF.)
- All fields may be left empty unless listed as Mandatory below.
- 1. Date
- Date of flight, in YYYY-MM-DD (dash-separated, preferred format), MM/DD/YYYY (slash-separated), DD.MM.YYYY (dot-separated) or YYYY (year-only) format. The date may optionally also contain the departure time of the flight in the format HH:MM[:SS], separated from the date by a space. Seconds are optional, but presently ignored. Mandatory (date part only).
- 2. From
- IATA or ICAO code of source airport. Mandatory unless "From_OID" is provided.
- 3. To
- IATA or ICAO code of destination airport. Mandatory unless "To_OID" is provided.
- 4. Flight_Number
- Flight number. If first two characters are an airline code (two alphanumeric digits), the code is used to override "Airline".
- 5. Airline
- Full name of airline name. Airline codes are not recognized. May be overridden by "Flight_Number", defaults to Unknown if not available.
- 6. Distance
- Distance of flight, in miles. Calculated automatically if not provided.
- 7. Duration
- Duration of flight, in the format HH:MM. Estimated automatically if not provided.
- 8. Seat
- Seat number.
- 9. Seat_Type
- Seat type: one of "W" for Window, "A" for Aisle or "M" for Middle.
- 10. Class
- Class: one of "F" for First, "C" for Business, "P" for Premium Economy, "Y" for Economy.
- 11. Reason
- Reason for flight: one of "B" for Business, "L" for Personal, "C" for Crew or "O" for Other.
- 12. Plane
- Plane type.
- 13. Registration
- Plane registration number.
- 14. Trip
- Internal OpenFlights Trip ID. Optional, but must exist and belong to the user importing the data if specified.
- 15. Note
- User-entered note or comment about flight.
The final four fields contain internal OpenFlights IDs (OID) for ensuring accurate imports. They are generated automatically when exporting, but should not
be provided if creating or importing your own data, or altering the airline, airport or plane fields of exported data.
- 16. From_OID
- Internal OpenFlights airport ID. Overrides "From" if provided.
- 17. To_OID
- Internal OpenFlights airport ID. Overrides "To" if provided.
- 18. Airline_OID
- Internal OpenFlights airline ID. Overrides "Airline" if provided.
- 19. Plane_OID
- Internal OpenFlights plane ID. Overrides "Plane" if provided.
Airlines are matched in the following order:
- "Airline_OID" as internal identifier
- First two characters of "Flight_Number" as IATA code, if alphanumeric and not numeric (AB, A1, 1A are OK, but 11 is not)
- "Airline" as name or alias
Note that the airline code (IATA/ICAO) must be supplied in "Flight_Number", not "Airline".
- If multiple matches are found, "Airline" is used to determine the best fit.
- If "Airline" is defined but no matches are found, "Airline" is added as new.
- If "Flight Number" defines an unrecognized IATA code, import fails.
- If neither "Airline" nor "Flight_Number" are defined, "Airline" is set to Unknown.
The following sample shows the maximal, recommended, and three minimal data sets for importing a flight (airline and flight number, airline only, and neither airline nor flight number).
2008-01-18 10:30:10,DXB,RUH,SV559,Saudi Arabian Airlines,542,01:35,40C,A,Y,B,Boeing 777,HZ-AKH,16,"First, to Saudi!",2188,2082,4533,3
2008-01-18 10:30,DXB,RUH,SV559,Saudi Arabian Airlines,542,01:35,40C,A,Y,B,Boeing 777,HZ-AKH,16,"First, to Saudi!"
2008-01-18,DXB,RUH,,Saudi Arabian Airlines
Note: The first line of any CSV file is always ignored, the field key is provided only for your own reference.
- 0.42 — Nov 7, 2010
- Fix representation of byte-order mark in UTF-8.
- 0.41 — Jul 21, 2009
- Clarified encoding.
- 0.4 — Feb 1, 2009
- Date field now allows optional time element.
- 0.3 — Dec 22, 2008
- Corrected business class specifier to "C", although "B" is still accepted. Support for American (DD/MM/YYYY) and European (DD.MM.YYYY) dates added.
- 0.2 — Dec 2, 2008
- Specifying airline no longer mandatory. Clarified field names, airline matching logic.
- 0.1 — Nov 30, 2008
- Original release.