Title: | Standard Schedules Information Parser |
---|---|
Description: | Parse Standard Schedules Information file (types 2 and 3) into a Data Frame. Can also expand schedules into flights. |
Authors: | Sebastien Thonnard |
Maintainer: | Sebastien Thonnard <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.1 |
Built: | 2025-02-03 02:53:30 UTC |
Source: | https://github.com/sthonnard/ssimparser |
Get the list of columns that can be parsed from SSIM.
get_ssim_collist(getall = TRUE)
get_ssim_collist(getall = TRUE)
getall |
Get all columns (TRUE/FALSE). |
Vector containing the SSIM columns.
# Get all columns get_ssim_collist() # Get some of the most 'useful' columns get_ssim_collist(FALSE)
# Get all columns get_ssim_collist() # Get some of the most 'useful' columns get_ssim_collist(FALSE)
Get a test SSIM file for validation and testing.
get_ssim_sample( datefrom = as.Date("2020-11-01"), dateto = as.Date("2020-12-01"), season = "W20", creadate = Sys.Date() )
get_ssim_sample( datefrom = as.Date("2020-11-01"), dateto = as.Date("2020-12-01"), season = "W20", creadate = Sys.Date() )
datefrom |
First date of the sample. |
dateto |
Last date of the sample. |
season |
IATA season (W20 = Winter 2020). |
creadate |
Creation date. Default today. |
A character vector containing the SSIM sample.
# Get sample sample_ssim_str <- ssimparser::get_ssim_sample(datefrom = as.Date("2020-11-01"), dateto = as.Date("2020-12-01"), season="W20") # Parse the sample into a data frame ssim_sample_df <- ssimparser::load_ssim(ssim_file = sample_ssim_str) head(ssim_sample_df, 10)
# Get sample sample_ssim_str <- ssimparser::get_ssim_sample(datefrom = as.Date("2020-11-01"), dateto = as.Date("2020-12-01"), season="W20") # Parse the sample into a data frame ssim_sample_df <- ssimparser::load_ssim(ssim_file = sample_ssim_str) head(ssim_sample_df, 10)
Load SSIM file into a Data Frame.
load_ssim( ssim_file = get_ssim_sample(), nested_df = FALSE, collist = get_ssim_collist(getall = FALSE), clean_col_names = TRUE, unpivot_days_of_op = FALSE, expand_sched = FALSE )
load_ssim( ssim_file = get_ssim_sample(), nested_df = FALSE, collist = get_ssim_collist(getall = FALSE), clean_col_names = TRUE, unpivot_days_of_op = FALSE, expand_sched = FALSE )
ssim_file |
Path to the SSIM file or character vector containing the content to load. |
nested_df |
Nest SSIM type 3 into type 2 (TRUE/FALSE). Default to FALSE. |
collist |
List of columns that need to be present in the final Data Frame. get_ssim_collist() to get the full list. |
clean_col_names |
Clean column names in the final Data Frame by removing type2/type3 prefixes (TRUE/FALSE). Default TRUE. |
unpivot_days_of_op |
Unpivot the schedules by creating a schedule by day of operation (TRUE/FALSE). Default FALSE. |
expand_sched |
Expand schedules into flights. |
Data Frame (nested or not) containing the schedules (or flights when schedules were expanded).
# Get a sample as a character vector sample_ssim_string <- ssimparser::get_ssim_sample(datefrom = as.Date("2020-11-01"), dateto = as.Date("2020-12-01"), season = "W20", creadate = as.Date("2020-12-02")) # Write sample to temp dir sample_ssim_file <- tempfile() write(sample_ssim_string, sample_ssim_file, append = FALSE) # Load sample, expand schedules to flights and display the traffic # by month and departure airport ICAO ssimparser::load_ssim(ssim_file = sample_ssim_file, expand_sched = TRUE) %>% dplyr::group_by(format(flight.flight_date,"%Y-%m"), adep_icao) %>% dplyr::summarise(n=dplyr::n()) # Get the unique list of airports ICAO ssimparser::load_ssim(ssim_file = sample_ssim_file, expand_sched = TRUE, collist = c("type3.adep_icao", "type3.ades_icao")) %>% unique() # Nest the type 3 into type 2 ssim_nested <- ssimparser::load_ssim(ssim_file = sample_ssim_file, expand_sched = FALSE, nested = TRUE) head(ssim_nested) # Remove the sample SSIM file unlink(sample_ssim_file)
# Get a sample as a character vector sample_ssim_string <- ssimparser::get_ssim_sample(datefrom = as.Date("2020-11-01"), dateto = as.Date("2020-12-01"), season = "W20", creadate = as.Date("2020-12-02")) # Write sample to temp dir sample_ssim_file <- tempfile() write(sample_ssim_string, sample_ssim_file, append = FALSE) # Load sample, expand schedules to flights and display the traffic # by month and departure airport ICAO ssimparser::load_ssim(ssim_file = sample_ssim_file, expand_sched = TRUE) %>% dplyr::group_by(format(flight.flight_date,"%Y-%m"), adep_icao) %>% dplyr::summarise(n=dplyr::n()) # Get the unique list of airports ICAO ssimparser::load_ssim(ssim_file = sample_ssim_file, expand_sched = TRUE, collist = c("type3.adep_icao", "type3.ades_icao")) %>% unique() # Nest the type 3 into type 2 ssim_nested <- ssimparser::load_ssim(ssim_file = sample_ssim_file, expand_sched = FALSE, nested = TRUE) head(ssim_nested) # Remove the sample SSIM file unlink(sample_ssim_file)
Load multiple SSIM file, expand to flights, and return the result as a Data Frame.
In case of period overlap for a specific flight date, information from the latest file will be used,
so beware of the file order in
parameter ssim_files.
load_ssim_flights( ssim_files = c("AFR_20201115.txt", "AFR_20201116.txt"), collist = get_ssim_collist(getall = FALSE), clean_col_names = TRUE )
load_ssim_flights( ssim_files = c("AFR_20201115.txt", "AFR_20201116.txt"), collist = get_ssim_collist(getall = FALSE), clean_col_names = TRUE )
ssim_files |
List of SSIM files to load, in the correct order (from the first to load to the last file to load). |
collist |
List of columns that need to be present in the final Data Frame. get_ssim_collist() to get the full list. |
clean_col_names |
Clean column names in the final Data Frame by removing type2/type3 prefixes (TRUE/FALSE). Default TRUE. |
Data Frame containing the flights.
# Get 3 samples as a character vector samples <- data.frame(sampleid = c(1:3)) %>% dplyr::rowwise() %>% dplyr::mutate( filename = tempfile(), samplestring = ssimparser::get_ssim_sample(datefrom = as.Date("2020-11-01") + (sampleid * 3), dateto = as.Date("2020-12-01") + (sampleid * 3), season = "W20", creadate = as.Date("2020-11-01") + sampleid) ) # Write the samples to tempdir for (i in 1:3) { write(samples[i,]$samplestring, samples[i,]$filename, append = FALSE) } # Load the 3 samples and display the total traffic per day ssimparser::load_ssim_flights(ssim_files = samples$filename) %>% dplyr::group_by(flight_date = as.Date(flight.flight_date)) %>% dplyr::summarise(total_flights = dplyr::n()) %>% dplyr::arrange(desc(flight_date)) # Unlink temp files for (i in 1:3) { unlink(samples[i,]$filename) }
# Get 3 samples as a character vector samples <- data.frame(sampleid = c(1:3)) %>% dplyr::rowwise() %>% dplyr::mutate( filename = tempfile(), samplestring = ssimparser::get_ssim_sample(datefrom = as.Date("2020-11-01") + (sampleid * 3), dateto = as.Date("2020-12-01") + (sampleid * 3), season = "W20", creadate = as.Date("2020-11-01") + sampleid) ) # Write the samples to tempdir for (i in 1:3) { write(samples[i,]$samplestring, samples[i,]$filename, append = FALSE) } # Load the 3 samples and display the total traffic per day ssimparser::load_ssim_flights(ssim_files = samples$filename) %>% dplyr::group_by(flight_date = as.Date(flight.flight_date)) %>% dplyr::summarise(total_flights = dplyr::n()) %>% dplyr::arrange(desc(flight_date)) # Unlink temp files for (i in 1:3) { unlink(samples[i,]$filename) }
Parse SSIM file (types 2 and 3) into a Data Frame.
Bugs report:
https://github.com/sthonnard/ssimparser
get_ssim_collist()
Get the list of columns that can be parsed from SSIM.
load_ssim(ssim_file)
Parse SSIM file into a Data Frame.
load_ssim_flights(ssim_files)
Parse multiple SSIM files, expand to flights, and return the result into a Data Frame.
get_ssim_sample()
Get a sample SSIM file as a character vector.