Commit e965418b authored by Douglas Goodwin's avatar Douglas Goodwin

2018-01-04 11:02:38 PST America/Los_Angeles

parent 087c30bd
# Los Angeles County Metropolitan Transportation Authority's GTFS for Rail.
## updated 2018-01-03 01:00:08 PST America/Los_Angeles
## updated 2018-01-04 11:02:38 PST America/Los_Angeles
As of May 6th, 2016 The LACMTA is now publishing our Bus and Rail Services in separate Google Transit Exports ONLY. As a customer service, and to allow us to update these files more frequently, we have split these files up. The new rail-only export will be updated Daily (generally Tuesday-Saturday mornings), to allow us to send out more timely information and to allow our users to capture all temporary rail service changes that may occur on a daily basis. The bus-only exports will continue to be provided as large-scale changes to the system occur -- generally once every one or two months. We will NOT continue to maintain the combined service feeds.
......@@ -9,41 +9,36 @@ As of May 6th, 2016 The LACMTA is now publishing our Bus and Rail Services in se
---
### Evergreen link to the gtfs_rail.zip archive: [https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip](https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip?1514970008.48)
### Evergreen link to the gtfs_rail.zip archive: [https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip](https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip?1515092558.82)
### Today's link to the gtfs_rail.zip archive: [https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip?1514970008.48](https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip?1514970008.48)
### Today's link to the gtfs_rail.zip archive: [https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip?1515092558.82](https://gitlab.com/LACMTA/gtfs_rail/raw/master/gtfs_rail.zip?1515092558.82)
### zip archive contents
```
Length Creation datetime Name
----------------------------------------------
173 2018-01-03 00:08 agency.txt
1527 2018-01-03 00:08 calendar.txt
467 2018-01-03 00:08 calendar_dates.txt
642 2018-01-03 00:08 routes.txt
273495 2016-03-16 15:09 shapes.txt
33465 2017-02-08 14:08 stops.txt
9758062 2018-01-03 00:08 stop_times.txt
482143 2018-01-03 00:08 trips.txt
283 2018-01-02 01:00 feed_info.txt
Length Creation datetime Name
-----------------------------------------------
173 2018-01-04 00:08 agency.txt
1586 2018-01-04 00:08 calendar.txt
323 2018-01-04 00:08 calendar_dates.txt
642 2018-01-04 00:08 routes.txt
273495 2016-03-16 15:09 shapes.txt
33465 2017-02-08 14:08 stops.txt
10274438 2018-01-04 00:08 stop_times.txt
492913 2018-01-04 00:08 trips.txt
283 2018-01-04 10:58 feed_info.txt
```
## Summary of changes
```
commit a6fc772b18425250ad54cf02436c19f31ff0b104
Author: metrodgoodwin <dgoodwin@gmail.com>
Date: Tue Jan 2 01:00:10 2018 -0800
2018-01-02 01:00:09 PST America/Los_Angeles
README.md | 38 +-
calendar.txt | 30 +-
calendar_dates.txt | 9 +-
gtfs_rail.zip | Bin 1322357 -> 1003504 bytes
stop_times.txt | 47258 ---------------------------------------------------
trips.txt | 2619 ---
6 files changed, 34 insertions(+), 49920 deletions(-)
commit 087c30bd37fb4547c78b2849574d836b2684b160
Author: Douglas Goodwin <goodwind@metro.net>
Date: Wed Jan 3 17:33:59 2018 -0800
set pickup_type = 1 or last stops in trip sequence
stop_times.txt | 226824 +++++++++++++++++++++++++++---------------------------
1 file changed, 113412 insertions(+), 113412 deletions(-)
```
## Subscribing to changes
......
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date
RDEC17-801-1_Weekday-09,1,1,1,1,1,0,0,20180103,20180103
RDEC17-801-1_Weekday-08,1,1,1,1,1,0,0,20180104,20180104
RDEC17-801-1_Weekday-98,1,1,1,1,1,0,0,20180105,20180112
RDEC17-801-2_Saturday-99,0,0,0,0,0,1,0,20180106,20180113
RDEC17-801-2_Saturday-03,0,0,0,0,0,1,0,20180106,20180106
RDEC17-801-3_Sunday-99,0,0,0,0,0,0,1,20180107,20180114
RDEC17-801-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180117
RDEC17-804-1_Weekday-16,1,1,1,1,1,0,0,20180103,20180104
RDEC17-804-1_Weekday-98,1,1,1,1,1,0,0,20180105,20180112
RDEC17-804-2_Saturday-99,0,0,0,0,0,1,0,20180106,20180113
RDEC17-801-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180118
RDEC17-801-2_Saturday-99,0,0,0,0,0,1,0,20180113,20180113
RDEC17-804-1_Weekday-16,1,1,1,1,1,0,0,20180104,20180104
RDEC17-804-1_Weekday-21,1,1,1,1,1,0,0,20180105,20180105
RDEC17-804-2_Saturday-09,0,0,0,0,0,1,0,20180106,20180106
RDEC17-804-3_Sunday-99,0,0,0,0,0,0,1,20180107,20180114
RDEC17-804-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180117
RDEC17-803-1_Weekday-20,1,1,1,1,1,0,0,20180103,20180103
RDEC17-804-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180118
RDEC17-804-1_Weekday-98,1,1,1,1,1,0,0,20180112,20180112
RDEC17-804-2_Saturday-99,0,0,0,0,0,1,0,20180113,20180113
RDEC17-803-1_Weekday-19,1,1,1,1,1,0,0,20180104,20180104
RDEC17-803-1_Weekday-21,1,1,1,1,1,0,0,20180105,20180105
RDEC17-803-2_Saturday-12,0,0,0,0,0,1,0,20180106,20180106
RDEC17-803-3_Sunday-99,0,0,0,0,0,0,1,20180107,20180114
RDEC17-803-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180117
RDEC17-803-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180118
RDEC17-803-1_Weekday-98,1,1,1,1,1,0,0,20180112,20180112
RDEC17-803-2_Saturday-99,0,0,0,0,0,1,0,20180113,20180113
RDEC17-802-1_Weekday-13,1,1,1,1,1,0,0,20180103,20180104
RDEC17-802-1_Weekday-13,1,1,1,1,1,0,0,20180104,20180104
RDEC17-802-1_Weekday-18,1,1,1,1,1,0,0,20180105,20180105
RDEC17-802CAR-2_Saturday-99,0,0,0,0,0,1,0,20180106,20180113
RDEC17-802CAR-3_Sunday-99,0,0,0,0,0,0,1,20180107,20180114
RDEC17-802CAR-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180117
RDEC17-802CAR-1_Weekday-99,1,1,1,1,1,0,0,20180108,20180118
RDEC17-802CAR-1_Weekday-98,1,1,1,1,1,0,0,20180112,20180112
......@@ -4,10 +4,6 @@ RDEC17-801-1_Weekday-98,20180109,2
RDEC17-801-1_Weekday-98,20180110,2
RDEC17-801-1_Weekday-98,20180111,2
RDEC17-801-1_Weekday-99,20180112,2
RDEC17-804-1_Weekday-98,20180108,2
RDEC17-804-1_Weekday-98,20180109,2
RDEC17-804-1_Weekday-98,20180110,2
RDEC17-804-1_Weekday-98,20180111,2
RDEC17-804-1_Weekday-99,20180112,2
RDEC17-803-1_Weekday-99,20180112,2
RDEC17-802CAR-1_Weekday-99,20180112,2
from ftplib import FTP
import sys
import sys, shutil, time
from os import stat
from string import Template
from datetime import datetime
import time
import git
import pytz
from zipfile import ZipFile
from texttable import Texttable
import pandas as pd
from myconfig import ftp_server, ftp_user, ftp_pass, remotepath, DEBUG, repodir
# this script grabs Metro's latest GTFS archive for Nextrail,
......@@ -21,6 +22,29 @@ r = git.Repo(repodir)
ftp = FTP(ftp_server)
ftp.login(ftp_user, ftp_pass)
def file_len(fname):
with open(fname) as f:
for i, l in enumerate(f):
pass
return i + 1
def updateTerminalPickups(stoptimesfile='stop_times.txt',DEBUG=False):
stop_times = stoptimesfile
fieldnames = ['trip_id','arrival_time','departure_time','stop_id','stop_sequence','stop_headsign','pickup_type','drop_off_type']
# create a dataframe from the stop_times_sorted.txt file
df = pd.read_csv(stop_times, usecols=fieldnames)
# Let's set the `pickup_type` column to 1 (indicating no pickup) on the last stop for every trip
df.loc[ df.groupby(['trip_id'], sort=False)['stop_sequence'].transform('idxmax'),'pickup_type' ]=1
# create the new csv
df.to_csv('stop_times.csv', columns=fieldnames, index=False, header=True)
# update the file
if (int( file_len('stop_times.csv') ) == int( file_len(stoptimesfile) )):
if DEBUG:
print('done!')
shutil.move('stop_times.csv', stoptimesfile)
else:
print('file length different')
def writeREADME(tpl='README.tpl', outfile='README.md', thevars={ 'thefiletable':'', 'thetimestamp':'', 'thegitlog':'', 'ts':'' }):
#open the template file
template_file = open( tpl )
......@@ -91,6 +115,9 @@ ts = time.time()
# unzip the contents
zobj.extractall()
# fix the pickup codes
updateTerminalPickups(stoptimesfile='stop_times.txt',DEBUG=DEBUG)
# let's update the README.md file
flist = zobj.namelist()
......
No preview for this file type
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment