Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created November 9, 2015 17:00
Show Gist options
  • Save anonymous/5becfef8427c6722543f to your computer and use it in GitHub Desktop.
Save anonymous/5becfef8427c6722543f to your computer and use it in GitHub Desktop.
restaurants = []
counter = 0
doc = Nokogiri::XML(File.open("big.xml", "r"))
doc.xpath('//row').each do |entry|
restaurant = map_to_restaurant(entry)
restaurants << rest
counter += 1
if counter % 1000 == 0
mongo.collection.insert_many(restaurants.map(&:to_h))
restaurants = []
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment