Skip to content

Instantly share code, notes, and snippets.

@timabell
Last active November 18, 2020 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timabell/3672e1b2850aab8a73d2697977de4492 to your computer and use it in GitHub Desktop.
Save timabell/3672e1b2850aab8a73d2697977de4492 to your computer and use it in GitHub Desktop.
Load a json file into an interactive ruby session https://twitter.com/tim_abell/status/1329010829874827265?s=20
#!/usr/bin/env ruby
require "json"
require "pry"
def load_json filename
puts "parsing #{filename} ..."
file = File.read filename
json = JSON.load file
puts "#{json.length} records loaded"
return json
end
data = load_json "data.json"
# drop to interactive ruby console for fast experimental analysis
binding.pry
@timabell
Copy link
Author

When run:

$ ./analyse.rb
parsing data.json ...
123456 records loaded
...
 => 25: binding.pry

[1] pry(main)> 

boom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment