Created
September 22, 2017 13:58
-
-
Save kp666/2876ea5cb3db88170a7bf3e52e623c5b 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
def process(file) | |
text = File.read(file) | |
string = text.lines.first | |
string.split(', ') | |
.map {|c| c.split("=")} | |
.inject({}) {|c, v| c[v[0]]=v[1].to_s.split(" ").map(&:to_i); c} | |
.inject([]) {|k, v| v[1].each {|i| k[i] = v[0]}; k} | |
.join | |
end | |
Dir["files/*.txt"].each do |file| | |
puts process(file) | |
end |
jikkujose
commented
Sep 22, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment