Last active
October 10, 2015 14:16
-
-
Save asterite/9d3041b35c4d1b1b9d2e 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
AI | Anguilla | |
---|---|---|
AL | Albania | |
AM | Armenia |
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
require "csv" | |
filename = ARGV[0] | |
# This reads the CSV and prints a Hash literal to the output | |
puts "{" | |
CSV.each_row(File.read(filename)) do |row| | |
print row[0].inspect | |
print " =>" | |
print row[1].inspect | |
puts "," | |
end | |
puts "}" | |
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
# This runs the load_countries program at compile time with "countries.csv" | |
# as an argument. The result of that execution is a hash literal: | |
# we paste it in the program (with {{ ... }}) | |
countries = {{ run("./load_countries", "./countries.csv") }} | |
p countries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment