This project is a scraper and analyzer for the on-time performance of the Long Island Rail Road (LIRR) trains. It fetches data from the LIRR's backend, processes it, and writes it to JSON and CSV files. It also prepares the data for Google Sheets.
- Collects data on train schedules and delays from the LIRR's backend
- Processes the data to calculate on-time performance metrics
- Writes the processed data to JSON and CSV files
- Prepares the data for Google Sheets
- Clone the repository:
git clone https://github.com/gramstudio/lirr-ontime.git
- Install the required dependencies:
npm install
- To write to Google Sheets, you will need a service account key with editor permissions. Otherwise, pipe the output to your preferred data storage.
- Copy the .env.sample file to a new file named
.env
:cp .env.sample .env
- Open the
.env
file and fill in the values forG_SERVICE_TOKEN
andG_SHEET_ID
.
- Run the script with
npm start
. This will fetch the data, process it, and write it to JSON and CSV files in thedata
directory. It will also prepare the data for Google Sheets. - Check the console for any logs or errors.
The project is written in TypeScript and uses the Google Sheets API to write data to Google Sheets. It also uses the d3-dsv library to format the data as CSV, and dayjs for date and time manipulation.
The main script is src/ts/index.ts, which fetches the data, processes it, and writes it. The data processing is done in src/ts/prepData.ts, and the writing is done in src/ts/writeData.ts).
You can debug the script using the configuration provided in .vscode/launch.json.