Applying GTFS-RT data to add delays
Due to the limited compatibility between the JSON data format and the GTFS-RT file, implementing the solution required a creative and somewhat indirect approach. A successful method for applying delays was identified: Processing full_gtfs_rt_data Each entry in full_gtfs_rt_data is matched with its corresponding trip_id in the stop_times.txt file. Identifying the delayed stop Within the identified trip_id, the stop with a registered delay in full_gtfs_rt_data is located. Moving to the previous stop The process moves one stop backward in stop_times.txt and locates this stop in the merged_connections_by_trips dataset. Extracting connection_id From the trip_id, a unique connection_id is extracted in the format, e.g., 12202411191321_<<<312>>>_012-11. Finding connection_id in connection data Using the extracted connection_id (e.g., 312), the connections data in merged_connections_by_trips is searched to link it with the previously identified stop. Converting delay time Delay times are converted from seconds into minutes for better readability and usage. Assigning delays to stops The delays from full_gtfs_rt_data are applied to the corresponding stops. he program outputs a JSON file: updated_connections_with_delays.json, which contains updated travel times to specific stations (including added delays) based on GTFS-RT data for ZTM