From 558c069607af2b47610a7711d09331089f92fcab Mon Sep 17 00:00:00 2001 From: Shrav Mehta Date: Wed, 24 Sep 2014 17:38:35 -0700 Subject: [PATCH] init --- .gitignore | 34 ++++++++++++++++++++++++++++++++++ LICENSE | 22 ++++++++++++++++++++++ README.md | 4 ++++ cleaner.rb | 21 +++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 cleaner.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2c1360 --- /dev/null +++ b/.gitignore @@ -0,0 +1,34 @@ +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/test/tmp/ +/test/version_tmp/ +/tmp/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalisation: +/.bundle/ +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1da7a14 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2014 Shrav Mehta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f5971f4 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +Address-Cleaner +=============== + +Verify and modify, if needed, a CSV of addresses. Great for incomplete addresses or incorrect addresses. diff --git a/cleaner.rb b/cleaner.rb new file mode 100644 index 0000000..c762304 --- /dev/null +++ b/cleaner.rb @@ -0,0 +1,21 @@ +require 'lob' +require 'csv' + +# Initialize Lob Object +Lob.api_key = 'xxx' +@lob = Lob.load + +# Row 0 is the Name. Other Rows are as Follows Below. + +CSV.open("new.csv", "wb") do |csv| + CSV.foreach("old.csv") do |row| + verify = @lob.addresses.verify( + address_line1: row[1], + address_line2: row[2], + city: row[3], + state: row[4], + zip: row[5] + ) + csv << [row[0], verify['address']['address_line1'], verify['address']['address_line2'], verify['address']['address_city'], verify['address']['address_state'], verify['address']['address_zip'], verify['address']['address_country']] + end +end