Created
January 12, 2011 04:03
-
-
Save c7/775677 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
iconv -t utf8 -c data/WebExtract.csv > data/web_extract_utf8.csv | |
iconv -t utf8 -c data/cuisine.csv > data/cuisine_utf8.csv |
This file contains 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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'csv' | |
require 'mongo' | |
db = Mongo::Connection.new.db("health_department") | |
cuisines = {} | |
CSV.foreach('data/cuisine_utf8.csv') do |row| | |
next if row[0] == 'CUISINECODE' | |
cuisines[row[0]] = row[1] | |
end | |
db['inspections'].drop | |
db['inspections'].ensure_index('camis') | |
CSV.foreach('data/web_extract_utf8.csv') do |row| | |
db['inspections'].insert({ | |
'camis' => row[0], | |
'dba' => row[1], | |
'boro' => row[2], | |
'building' => row[3], | |
'street' => row[4], | |
'zip_code' => row[5], | |
'phone' => row[6], | |
'cuisine_code' => row[7], | |
'cuisine_description' => cuisines[row[7]], | |
'inspection_date' => row[8], | |
'action' => row[9], | |
'violation_code' => row[10], | |
'score' => row[11], | |
'current_grade' => row[12], | |
'grade_date' => row[13], | |
'record_date' => row[14] | |
}) | |
end | |
db['inspections'].remove({ 'camis' => 'CAMIS' }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment