toddwschneider/nyc-subway-turnstile-data

Support for earlier data file format

Opened this issue · 3 comments

I'd love to be able to see the earlier data too on these graphs. If this isn't something you're currently working on, do you have any tips for where I (or someone else) might begin making changes?

Hi @RSully, it's not something I'm working on, but I don't think it would be too hard to do. The old file format is available here on the MTA's website

You'd want to update the import_turnstile_observations method in app/models/turnstile_observation.rb so that it can handle either format. The parts of that method that download the files and copy the rows to the database should probably be shared for both file types, but the part of the code that converts the raw file into rows for copy would need to be different. If I were doing it myself I'd probably have a method called something like def rows_from_raw_data(filename:) which under the hood decides how to convert the raw file to rows for copy

Thanks for the tips. As someone who doesn't really do a lot of Ruby work, could you give a quick summary of how to get up and running? I've installed an up to date Ruby from Homebrew and have it first in my PATH, but not exactly sure on the commands to install dependencies and run a test server.

@RSully I'm not sure I can provide a thorough overview of getting started with Ruby/Rails, but here's a short version of one particular setup that would work. You might decide for a different setup

  • I use rbenv to manage Ruby versions, it's available via Homebrew
  • After setting up Ruby, you might need to install bundler manually by typing gem install bundler at your command line
  • Install PostgreSQL, also via Homebrew, then follow instructions to make sure your server is running locally
  • Once Ruby and Postgres are installed correctly, you should be able to run bundle exec rake db:setup from this repository's root directory and that will create the database with the correct schema
  • I can't provide a full guide on how to interact with the Rails console, but would suggest you take a look at the official Ruby on Rails guides to learn more

Hope this helps, thanks