Skip to content

Instantly share code, notes, and snippets.

@seeflanigan
Created July 2, 2016 20:48
Show Gist options
  • Save seeflanigan/87d3a2dec831f06ce5a316fee2fbb12a to your computer and use it in GitHub Desktop.
Save seeflanigan/87d3a2dec831f06ce5a316fee2fbb12a to your computer and use it in GitHub Desktop.
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
@JoshCheek
Copy link

Oh, maybe you transcribed it into this gist and changed some names? Otherwise, its not clear to me why attrs are pulled from Reading, but then assigned to Record.

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