こんにちは、私は Python の初心者で、現在学習中です。私が直面している問題について誰かが私を助けてくれるかどうか疑問に思っていました。routes.txt、trips.txt、stop_times.txt、stops.txt の 4 つのファイルがあります。ファイルは次のようになります (ファイルには数千行あります)。
routes.txt
"route_id","agency_id","route_short_name","route_long_name","route_desc","route_type","route_url","route_color","route_text_color"
"01","1","1",,,3,,"FFFF7C","000000"
"04","1","4",,,3,,"FFFF7C","000000"
"05","1","5",,,3,,"FFFF7C","000000"
"07","1","7",,,3,,"FFFF7C","000000"
trips.txt
"route_id","service_id","trip_id","trip_headsign","direction_id","block_id","shape_id"
"108","BUSN13-hbf13011-Weekday-02","19417636","Malden Station via Salem St.",1,"F411-75","1080037"
"94","BUSN13-hbf13011-Weekday-02","19417637","Medford Square via West Medford",0,"F94-5","940014"
stop_times.txt
"trip_id","arrival_time","departure_time","stop_id","stop_sequence","stop_headsign","pickup_type","drop_off_type"
"19417636","14:40:00","14:40:00","7412",1,,0,0
"19417636","14:41:00","14:41:00","6283",2,,0,0
"19417636","14:41:00","14:41:00","6284",3,,0,0
stops.txt
stop_id","stop_code","stop_name","stop_desc","stop_lat","stop_lon","zone_id","stop_url","location_type","parent_station"
"place-alfcl","","Alewife Station","","42.395428","-71.142483","","",1,""
"place-alsgr","","Allston St. Station","","42.348701","-71.137955","","",1,""
"place-andrw","","Andrew Station","","42.330154","-71.057655","","",1,""
列 ID に基づいて行を印刷しようとしています。たとえば、route_id = "01" の場合。
check the ID in the routes.txt file and check if that ID is equal to the route_id in the Trips.txt file.
試合が同点の場合
take the trip_id from the trips.txt file and compare it with the trip_id in the stop_times.txt file
それが一致する場合は、
stop_id is equal to the stop_id of the stops_file.txt file then print. Now the stop_id can be a number or a string
私が印刷しようとしているのは、たとえば次のようなものを印刷することです。
route_id, trip_id, arrival_time, departure_time, stop_name
01,19417636, 14:40:00,14:40:00, Alewife Station
とても有難い