Skip to content

Instantly share code, notes, and snippets.

@matschaffer
Forked from graybill/gist:906895
Created April 7, 2011 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matschaffer/906896 to your computer and use it in GitHub Desktop.
Save matschaffer/906896 to your computer and use it in GitHub Desktop.
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