Created
February 25, 2017 23:50
-
-
Save tmcw/e87f3c789c49e76f65156d7d7f3ecbef to your computer and use it in GitHub Desktop.
This file contains 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
require 'json' | |
artists = {} | |
Dir.glob('charts/*').select do |f| | |
contents = File.read(f) | |
chart = JSON.load(contents) | |
chart.each.with_index do |song, i| | |
unless artists.has_key?(song['artist']) | |
artists[song['artist']] = {} | |
end | |
unless artists[song['artist']].has_key?(song['title']) | |
reduced = { | |
:title => song['title'], | |
:artist => song['artist'], | |
:positions => [] | |
} | |
artists[song['artist']]['title'] = reduced | |
end | |
artists[song['artist']]['title'][:positions] << [f.split('/')[1], i] | |
end | |
end | |
JSON.dump(artists, File.open("./reduced.json", "w")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Haskell implementation ~2hrs in, no luck so far. Starting on rust implementation.