gtfs
gtfs copied to clipboard
@trip_id returns nil
The variable trip_id from stop_times comes nil everytime its called.
I dont know why, because the content of the class is:
<GTFS::StopTime:0x99bffc4 @trip_id="SA00100310", @arrival_time="13:19:00", @departure_time="13:19:00", @stop_id="4514", @stop_sequence="1", @stop_headsign=nil, @pickup_type=nil, @drop_off_type=nil, @shape_dist_traveled="0">
And row.trip_id returns 'nil'
The problem comes when reading a UTF-8 BOM, because it contains "\xEF\xBB\xBF".
@trip_id will be declared as "@\xEF\xBB\xBFtrip_id".
"#<GTFS::StopTime:0x8b9a638 @\xEF\xBB\xBFtrip_id=\"FE00100317\", @arrival_time=\"17:37:44\", @departure_time=\"17:37:44\", @stop_id=\"168\", @stop_sequence=\"19\", @stop_headsign=nil, @pickup_type=nil, @drop_off_type=nil, @shape_dist_traveled=\"6183\">"
should be
"#<GTFS::StopTime:0x8b9a638 @trip_id=\"FE00100317\", @arrival_time=\"17:37:44\", @departure_time=\"17:37:44\", @stop_id=\"168\", @stop_sequence=\"19\", @stop_headsign=nil, @pickup_type=nil, @drop_off_type=nil, @shape_dist_traveled=\"6183\">"
I fixed it for my self replacing the method initialize from Model whit:
attrs.each do |key, val|
realkey = key.gsub("\xEF\xBB\xBF".force_encoding("UTF-8"), "")
instance_variable_set("@#{realkey}", val)
end
(I know it sucks)
Thanks for the bug report @muit! Sorry for the late reply, I was on vacation when you reported the issue and I'm just catching up.
Happily you seem to have found a workaround for the time being. I'll try and find some time in the near future to look at this more closely... but until then if you come across any solutions your happy with I'd happily accept pull requests (with passing tests) and cut a new release on rubygems.
Thanks again!