Created
September 11, 2013 21:15
-
-
Save davidalpert/6529900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'json' | |
| require 'rake' | |
| require 'date' | |
| #include FileUtils | |
| pattern_to_search = "./path/to/files/*.json" | |
| def get_date_from_filename(f) | |
| match = f.match /.*_(\d+)_(\d+)_(\d+)$/ | |
| year = match[1] | |
| month = match[2] | |
| day = match[3] | |
| Date.new(year, month, day) | |
| end | |
| def read_one_file(f) | |
| data = "" | |
| File.open(f, "r") do |fileData| | |
| data = JSON.parse(f) | |
| end | |
| data | |
| end | |
| puts "Scanning #{pattern_to_search}" | |
| FileList[pattern_to_search].each do |f| | |
| #puts "- reading: #{f}" | |
| date = get_date_from_filename(f) rescue DateTime.now | |
| data = read_one_file(f) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment