Created
July 2, 2016 20:48
-
-
Save seeflanigan/87d3a2dec831f06ce5a316fee2fbb12a 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
def attrs | |
@attrs ||= Reading.new.attributes.keys.take(5).last(4) | |
end | |
def data | |
@data ||= File.read("tmp/output_small_test.csv") | |
end | |
def rows | |
data.split() | |
end | |
def cells | |
rows.map {|r| r.split(",") } | |
end | |
def hashes | |
cells.map do |row| | |
attrs.zip(row). | |
map {|lbl, val| {lbl.to_sym => val }}. | |
reduce(&:merge) | |
end | |
end | |
def readings | |
hashes.map {|r| Record.new(r) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, maybe you transcribed it into this gist and changed some names? Otherwise, its not clear to me why
attrs
are pulled fromReading
, but then assigned toRecord
.