Skip to content

Instantly share code, notes, and snippets.

@charliemcelfresh
Created April 4, 2013 00:29
Show Gist options
  • Save charliemcelfresh/5306706 to your computer and use it in GitHub Desktop.
Save charliemcelfresh/5306706 to your computer and use it in GitHub Desktop.
## 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