Created
April 4, 2013 00:29
-
-
Save charliemcelfresh/5306706 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
## where header is the first line, and data is a data line | |
Hash[header.zip(data.map{|d| d})].map{|k, v| transform_key_value(k, v)} | |
def transform_key_value(k, v) | |
if v == "true" | |
[k, true] | |
elsif k == "neighborhood" || k == "cuisine" || k == "category_labels" | |
[k, v.split(",").map{|e| e.strip}] | |
elsif k == "hours" | |
v == "" ? [k, v] : [k, hours(v)] | |
else | |
[k, v] | |
end | |
end | |
def hours | |
## not quite done with this | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment