Created
August 28, 2012 18:38
-
-
Save lenagroeger/3501903 to your computer and use it in GitHub Desktop.
Faster CSV for bar graphs
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 'rubygems' | |
require 'fastercsv' | |
data = [] | |
html = <<-HTML | |
HTML | |
FasterCSV.foreach("fda.csv", :headers => true) do |row| | |
data << row | |
end | |
data.each do |row| | |
el = <<-HTML | |
<div class="fda-graph-container"> | |
<div class="fda-bar" style="height:#{((row["regular"].to_f))}%" data-year = "#{row["year"]}" data-specific = "#{row["regular"]}" data-total = "#{row["total"]}"> | |
</div> | |
</div> | |
HTML | |
html << el | |
end | |
html << <<-HTML | |
HTML | |
File.open("fda.html", "w") do |f| | |
f.write html | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment