-
-
Save matschaffer/906896 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
require 'csv' | |
def coordinates(addr) | |
include Geokit::Geocoders | |
res=MultiGeocoder.geocode(addr) | |
res.ll | |
end | |
namespace :import do | |
desc 'Parse CSV files and import into the database' | |
task :non_store_csv => :environment do | |
file = "/Users/admin/code/tubfinder/public/data/nonstore.csv" | |
CSV.foreach file do |row| | |
addr = row[1] + " " + row[2] + "," + row[5] | |
loc = coordinates(addr) | |
p loc | |
l = Location.new( | |
:name => row[0], | |
:address => addr, | |
:loc_type => 'bar', | |
:zipcode => row[5] | |
) | |
l.loc = loc | |
l.save | |
p l | |
end | |
p Location.all.count | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment