Last active
August 29, 2015 13:57
-
-
Save rwarbelow/9533533 to your computer and use it in GitHub Desktop.
We took zip codes from a CSV file. We checked to see if the zip code was nil or less than five digits. If so, we fixed the zip code by adding 0s or putting "no zip code."
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
| RegDate | first_Name | last_Name | Email_Address | HomePhone | Street | City | State | Zipcode | ||
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 11/12/08 10:47 | Allison | Nguyen | [email protected] | 6154385000 | 3155 19th St NW | Washington | DC | 20010 | |
| 2 | 11/12/08 13:23 | SArah | Hankins | [email protected] | 414-520-5000 | 2022 15th Street NW | Washington | DC | 20009 | |
| 3 | 11/12/08 13:30 | Sarah | Xx | [email protected] | (941)979-2000 | 4175 3rd Street North | Saint Petersburg | FL | 33703 | |
| 4 | 11/25/08 19:21 | David | Thomas | [email protected] | 650-799-0000 | 9 garrison ave | Jersey City | NJ | 7306 | |
| 5 | 2/2/09 11:29 | Chris | Sackett | [email protected] | 613 565-4000 | 173 Daly Ave | Ottawa | ON | ||
| 6 | 11/12/08 15:00 | Aya | Fuller | [email protected] | 778.232.7000 | 2-1325 Barclay Street | Vancouver | BC | 90210 | |
| 7 | 11/12/08 16:05 | Mary Kate | Curry | [email protected] | (202) 328 1000 | 1509 Jackson Street | Baltimore | MD | 21230 | |
| 8 | 11/12/08 17:18 | Audrey | Hasegan | [email protected] | 530-919-3000 | 1570 Old Ranch Rd. | Placerville | CA | 95667 | |
| 9 | 11/13/08 1:32 | Shiyu | Armideo | [email protected] | 8084974000 | 644 Ikemaka PL | Kailua | HI | 96734 | |
| 10 | 11/13/08 16:40 | Eli | Zielke | [email protected] | 858 405 3000 | 3024 Cranbrook Ct | La Jolla | CA | 92037 | |
| 11 | 11/13/08 18:17 | Colin | Harmston | [email protected] | 14018685000 | 34 blue heron drive | attleboro | MA | 2703 | |
| 12 | 11/13/08 21:19 | Megan | Doe | [email protected] | 315.450.6000 | 64 King Ave | Columbus | OH | 43201 | |
| 13 | 11/16/08 11:44 | Meggie | Tippit | [email protected] | 510 282 4000 | 28 Olive Ave. | Piedmont | CA | 94611 | |
| 14 | 11/16/08 13:54 | Laura | Rapetsky | [email protected] | 787-295-0000 | Urb Monte Carlo c/15#1287 | San Juan | PR | 924 | |
| 15 | 11/16/08 20:20 | Paul | Fulghum | [email protected] | 9.82E+00 | shohadaye sadeghiye | Tehran | YK | 14517 | |
| 16 | 11/17/08 19:41 | Shannon | Warner | [email protected] | (603) 305-3000 | 186 Crooked S Road | Lyndeborough | NH | 3082 | |
| 17 | 11/19/08 21:56 | Shannon | Davis | [email protected] | 530-355-7000 | Campion 1108 914 E. Jefferson | Seattle | WA | 98122 | |
| 18 | 11/20/08 16:25 | Nash | Okaty | [email protected] | 206-226-3000 | 914 E Jefferson ST | Seattle | WA | 98122 | |
| 19 | 11/23/08 20:44 | Amanda | Hartzell | [email protected] | 607-280-2000 | 3515 School St | Valois | NY | 14841 |
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 fix_zipcode(zipcode) | |
| if zipcode.nil? | |
| zipcode = "No zipcode" | |
| elsif zipcode.length < 5 | |
| zipcode = zipcode.rjust(5, "0") | |
| end | |
| puts zipcode | |
| end | |
| puts "EventManager Initialized!" | |
| contents = CSV.open("event_attendees.csv", headers: true, header_converters: :symbol) | |
| contents.each do |row| | |
| zipcode = row[:zipcode] | |
| fix_zipcode(zipcode) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment