diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4bd0b2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,52 @@ +.DS_Store + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# Eclipse Core +.project + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ diff --git a/PovertyInfo/src/interactiveinfo/GetPovertyInfo.java b/PovertyInfo/src/interactiveinfo/GetPovertyInfo.java new file mode 100644 index 0000000..3c01f56 --- /dev/null +++ b/PovertyInfo/src/interactiveinfo/GetPovertyInfo.java @@ -0,0 +1,30 @@ +package interactiveinfo; + +import java.util.Scanner; +import java.io.File; +import java.io.FileNotFoundException; + +public class GetPovertyInfo { + + public static String getMatch(String county) throws FileNotFoundException { + File data = new File("support/povWA.txt"); + Scanner scnr = new Scanner(data); + scnr.nextLine(); // skip first line + + while(scnr.hasNextLine()) { + String line = scnr.nextLine(); + if ((county + " County").equals(line.substring(193, 238).trim()) ) { + String match = line; + scnr.close(); + return match; + } + } + + scnr.close(); + return null; + } + + public static void printCountyInfo(String countyRecord) { + System.out.println(String.format("In %s, %s children (%s%%) are in poverty. The median household income is $%s.", countyRecord.substring(193, 239).trim(), countyRecord.substring(49, 57).trim(), countyRecord.substring(76, 80).trim(), countyRecord.substring(133, 139).trim())); + } +} diff --git a/PovertyInfo/src/interactiveinfo/Program.java b/PovertyInfo/src/interactiveinfo/Program.java new file mode 100644 index 0000000..3a85924 --- /dev/null +++ b/PovertyInfo/src/interactiveinfo/Program.java @@ -0,0 +1,35 @@ +package interactiveinfo; + +import java.io.FileNotFoundException; +import java.util.Scanner; + +import org.apache.commons.lang3.text.WordUtils; + +public class Program { + + public static void main(String[] args) throws FileNotFoundException { + Scanner scnr = new Scanner(System.in); + System.out.println("Enter a county name in Washington (e.g., King), or type `quit` to quit: "); + String input = WordUtils.capitalizeFully(scnr.nextLine().trim()); + + String record = null; + while (!input.equals("Quit") && !input.equals("Q")) { + record = GetPovertyInfo.getMatch(input); + + while (record == null) { + scnr = new Scanner(System.in); + System.out.println("No match found. Try again: "); + input = WordUtils.capitalizeFully(scnr.nextLine().trim()); + record = GetPovertyInfo.getMatch(input); + } + + GetPovertyInfo.printCountyInfo(record); + scnr = new Scanner(System.in); + System.out.println("Enter another county, or type `quit` to quit: "); + input = WordUtils.capitalizeFully(scnr.nextLine().trim()); + } + + scnr.close(); + } + +} diff --git a/PovertyInfo/src/stateinfo/GetPovertyInfo.java b/PovertyInfo/src/stateinfo/GetPovertyInfo.java new file mode 100644 index 0000000..19c002a --- /dev/null +++ b/PovertyInfo/src/stateinfo/GetPovertyInfo.java @@ -0,0 +1,87 @@ +package stateinfo; + +import java.util.Scanner; +import java.io.File; +import java.util.HashMap; +import java.util.Map; +import java.io.FileNotFoundException; + +public class GetPovertyInfo { + + private static final Map stateFiles; + static + { + stateFiles = new HashMap(); + stateFiles.put("Washington", "support/povWA.txt"); + stateFiles.put("South Dakota", "support/povSD.txt"); + } + + public static String getMinimumChildPovertyRecord(String state) throws FileNotFoundException { + File data = new File(stateFiles.get(state)); + Scanner scnr = new Scanner(data); + + scnr.nextLine(); // skip first line + + String minCountyRecord = null; + Double currentMin = null; + + while(scnr.hasNextLine()){ + + String line = scnr.nextLine(); + + if (currentMin == null) { + currentMin = Double.parseDouble(line.substring(76, 80)); + minCountyRecord = line; + } + + if (Double.parseDouble(line.substring(76, 80)) < currentMin) { + currentMin = Double.parseDouble(line.substring(76, 80)); + minCountyRecord = line; + } + + } + + scnr.close(); + return minCountyRecord; + } + + public static String getMaximumChildPovertyRecord(String state) throws FileNotFoundException { + File data = new File(stateFiles.get(state)); + Scanner scnr = new Scanner(data); + + scnr.nextLine(); // skip first line + + String maxCountyRecord = null; + Double currentMax = null; + + while(scnr.hasNextLine()){ + + String line = scnr.nextLine(); + + if (currentMax == null) { + currentMax = Double.parseDouble(line.substring(76, 80)); + maxCountyRecord = line; + } + + if (Double.parseDouble(line.substring(76, 80)) > currentMax) { + currentMax = Double.parseDouble(line.substring(76, 80)); + maxCountyRecord = line; + } + + } + + scnr.close(); + return maxCountyRecord; + } + + public static void printChildPovertyInfo(String state) throws FileNotFoundException { + String minCountyRecord = GetPovertyInfo.getMinimumChildPovertyRecord(state); + String maxCountyRecord = GetPovertyInfo.getMaximumChildPovertyRecord(state); + + System.out.println(String.format("In %s:", state)); + System.out.println(String.format("The county with the lowest percentage of children in poverty is %s. In that county, %s children (%s%%) are in poverty. The median household income is $%s.", minCountyRecord.substring(193, 239).trim(), minCountyRecord.substring(49, 57).trim(), minCountyRecord.substring(76, 80).trim(), minCountyRecord.substring(133, 139).trim())); + System.out.println(String.format("The county with the highest percentage of children in poverty is %s. In that county, %s children (%s%%) are in poverty. The median household income is $%s.", maxCountyRecord.substring(193, 239).trim(), maxCountyRecord.substring(49, 57).trim(), maxCountyRecord.substring(76, 80).trim(), maxCountyRecord.substring(133, 139).trim())); + + } + +} diff --git a/PovertyInfo/src/stateinfo/Program.java b/PovertyInfo/src/stateinfo/Program.java new file mode 100644 index 0000000..177befc --- /dev/null +++ b/PovertyInfo/src/stateinfo/Program.java @@ -0,0 +1,12 @@ +package stateinfo; + +import java.io.FileNotFoundException; + +public class Program { + + public static void main(String[] args) throws FileNotFoundException { + GetPovertyInfo.printChildPovertyInfo("Washington"); + GetPovertyInfo.printChildPovertyInfo("South Dakota"); + } + +} diff --git a/PovertyInfo/support/commons-lang3-3.4.jar b/PovertyInfo/support/commons-lang3-3.4.jar new file mode 100644 index 0000000..8ec91d4 Binary files /dev/null and b/PovertyInfo/support/commons-lang3-3.4.jar differ diff --git a/PovertyInfo/support/povSD.txt b/PovertyInfo/support/povSD.txt new file mode 100644 index 0000000..7c6eaac --- /dev/null +++ b/PovertyInfo/support/povSD.txt @@ -0,0 +1,67 @@ +46 0 115906 111520 120292 14.1 13.6 14.6 37836 35834 39838 18.4 17.4 19.4 23496 21935 25057 16.1 15.0 17.2 51059 50111 52007 13429 12229 14629 22.7 20.7 24.7 South Dakota SD est14_SD.txt 06NOV2015 +46 3 287 226 348 10.8 8.5 13.1 97 73 121 14.5 11.0 18.0 63 46 80 12.9 9.5 16.3 50896 46912 54880 Aurora County SD est14_SD.txt 06NOV2015 +46 5 2685 2165 3205 15.1 12.2 18.0 989 747 1231 22.0 16.6 27.4 638 462 814 21.3 15.4 27.2 49583 46379 52787 Beadle County SD est14_SD.txt 06NOV2015 +46 7 1182 927 1437 34.8 27.3 42.3 525 401 649 45.5 34.8 56.2 338 253 423 41.1 30.7 51.5 34326 30850 37802 Bennett County SD est14_SD.txt 06NOV2015 +46 9 848 662 1034 15.2 11.9 18.5 229 174 284 18.3 13.9 22.7 150 111 189 16.0 11.9 20.1 47987 43732 52242 Bon Homme County SD est14_SD.txt 06NOV2015 +46 11 4230 3552 4908 14.1 11.8 16.4 747 566 928 11.5 8.7 14.3 469 344 594 10.5 7.7 13.3 52930 48346 57514 Brookings County SD est14_SD.txt 06NOV2015 +46 13 4375 3634 5116 11.8 9.8 13.8 1185 917 1453 13.2 10.2 16.2 728 539 917 11.4 8.4 14.4 53150 48208 58092 Brown County SD est14_SD.txt 06NOV2015 +46 15 769 613 925 14.8 11.8 17.8 249 193 305 19.0 14.7 23.3 154 115 193 16.5 12.3 20.7 47224 42548 51900 Brule County SD est14_SD.txt 06NOV2015 +46 17 841 667 1015 40.7 32.3 49.1 395 302 488 47.5 36.3 58.7 249 184 314 44.6 32.9 56.3 21658 19379 23937 Buffalo County SD est14_SD.txt 06NOV2015 +46 19 1605 1285 1925 15.8 12.7 18.9 558 422 694 22.6 17.1 28.1 365 269 461 20.0 14.7 25.3 41446 37285 45607 Butte County SD est14_SD.txt 06NOV2015 +46 21 129 99 159 9.4 7.2 11.6 21 16 26 9.5 7.1 11.9 15 11 19 8.9 6.5 11.3 49895 44691 55099 Campbell County SD est14_SD.txt 06NOV2015 +46 23 2128 1741 2515 24.0 19.6 28.4 825 634 1016 31.4 24.1 38.7 512 379 645 27.9 20.7 35.1 41395 37566 45224 Charles Mix County SD est14_SD.txt 06NOV2015 +46 25 474 374 574 13.8 10.9 16.7 176 135 217 25.6 19.6 31.6 109 80 138 23.7 17.5 29.9 48024 43064 52984 Clark County SD est14_SD.txt 06NOV2015 +46 27 2941 2514 3368 24.9 21.3 28.5 458 348 568 18.3 13.9 22.7 279 205 353 16.4 12.1 20.7 43453 39509 47397 Clay County SD est14_SD.txt 06NOV2015 +46 29 2848 2246 3450 10.3 8.1 12.5 919 692 1146 13.6 10.2 17.0 576 422 730 12.1 8.9 15.3 52892 47782 58002 Codington County SD est14_SD.txt 06NOV2015 +46 31 1612 1325 1899 38.6 31.7 45.5 650 503 797 45.2 35.0 55.4 408 307 509 39.1 29.4 48.8 31420 28934 33906 Corson County SD est14_SD.txt 06NOV2015 +46 33 876 681 1071 10.7 8.3 13.1 237 177 297 18.7 13.9 23.5 162 118 206 17.3 12.7 21.9 51244 46078 56410 Custer County SD est14_SD.txt 06NOV2015 +46 35 2351 1844 2858 12.3 9.6 15.0 658 499 817 14.7 11.2 18.2 418 308 528 13.0 9.6 16.4 48675 43725 53625 Davison County SD est14_SD.txt 06NOV2015 +46 37 888 729 1047 16.3 13.4 19.2 243 186 300 19.7 15.1 24.3 159 119 199 17.6 13.2 22.0 43305 38690 47920 Day County SD est14_SD.txt 06NOV2015 +46 39 430 343 517 10.1 8.1 12.1 127 95 159 12.8 9.6 16.0 84 61 107 11.2 8.1 14.3 51246 46436 56056 Deuel County SD est14_SD.txt 06NOV2015 +46 41 1535 1238 1832 27.2 21.9 32.5 641 479 803 32.7 24.4 41.0 419 301 537 32.5 23.4 41.6 34936 31499 38373 Dewey County SD est14_SD.txt 06NOV2015 +46 43 330 256 404 11.6 9.0 14.2 94 71 117 14.4 10.8 18.0 60 44 76 12.9 9.4 16.4 49251 44041 54461 Douglas County SD est14_SD.txt 06NOV2015 +46 45 397 307 487 10.5 8.1 12.9 111 83 139 13.9 10.4 17.4 70 51 89 12.0 8.7 15.3 57148 51209 63087 Edmunds County SD est14_SD.txt 06NOV2015 +46 47 1135 926 1344 17.0 13.9 20.1 299 229 369 24.4 18.6 30.2 194 143 245 19.5 14.4 24.6 42007 38058 45956 Fall River County SD est14_SD.txt 06NOV2015 +46 49 288 224 352 13.2 10.2 16.2 82 61 103 21.3 15.7 26.9 52 37 67 20.2 14.5 25.9 46633 41777 51489 Faulk County SD est14_SD.txt 06NOV2015 +46 51 725 559 891 10.0 7.7 12.3 219 166 272 13.5 10.2 16.8 141 102 180 11.7 8.5 14.9 52816 47953 57679 Grant County SD est14_SD.txt 06NOV2015 +46 53 761 598 924 18.3 14.4 22.2 255 192 318 27.0 20.3 33.7 166 121 211 23.5 17.1 29.9 36836 33215 40457 Gregory County SD est14_SD.txt 06NOV2015 +46 55 217 170 264 12.0 9.4 14.6 64 48 80 15.3 11.4 19.2 42 30 54 14.0 10.0 18.0 43699 39049 48349 Haakon County SD est14_SD.txt 06NOV2015 +46 57 607 476 738 10.4 8.1 12.7 238 180 296 12.8 9.7 15.9 156 113 199 12.2 8.9 15.5 53944 49055 58833 Hamlin County SD est14_SD.txt 06NOV2015 +46 59 329 261 397 10.0 7.9 12.1 84 64 104 12.0 9.1 14.9 53 39 67 10.0 7.3 12.7 51201 45889 56513 Hand County SD est14_SD.txt 06NOV2015 +46 61 260 198 322 8.1 6.2 10.0 142 106 178 15.2 11.3 19.1 89 64 114 14.2 10.2 18.2 61945 55975 67915 Hanson County SD est14_SD.txt 06NOV2015 +46 63 137 106 168 11.2 8.6 13.8 38 28 48 14.8 11.0 18.6 25 18 32 15.9 11.4 20.4 49220 44193 54247 Harding County SD est14_SD.txt 06NOV2015 +46 65 1853 1487 2219 11.0 8.8 13.2 616 475 757 14.9 11.5 18.3 375 278 472 12.9 9.6 16.2 58340 53108 63572 Hughes County SD est14_SD.txt 06NOV2015 +46 67 884 695 1073 13.2 10.4 16.0 288 218 358 20.4 15.4 25.4 185 135 235 18.4 13.4 23.4 48879 44412 53346 Hutchinson County SD est14_SD.txt 06NOV2015 +46 69 137 107 167 10.1 7.9 12.3 25 19 31 8.4 6.3 10.5 16 12 20 7.0 5.1 8.9 49184 44123 54245 Hyde County SD est14_SD.txt 06NOV2015 +46 71 1097 874 1320 33.9 27.0 40.8 479 364 594 43.3 32.9 53.7 303 224 382 40.5 29.9 51.1 31922 28664 35180 Jackson County SD est14_SD.txt 06NOV2015 +46 73 283 223 343 14.9 11.8 18.0 74 56 92 18.5 13.9 23.1 46 33 59 16.8 12.2 21.4 48773 43655 53891 Jerauld County SD est14_SD.txt 06NOV2015 +46 75 127 98 156 13.1 10.1 16.1 47 35 59 23.2 17.3 29.1 31 22 40 20.0 14.3 25.7 44876 40072 49680 Jones County SD est14_SD.txt 06NOV2015 +46 77 498 396 600 10.1 8.0 12.2 142 107 177 13.1 9.9 16.3 93 68 118 12.2 8.9 15.5 51837 46873 56801 Kingsbury County SD est14_SD.txt 06NOV2015 +46 79 1102 848 1356 9.5 7.3 11.7 268 200 336 11.4 8.5 14.3 173 125 221 10.3 7.5 13.1 53175 47608 58742 Lake County SD est14_SD.txt 06NOV2015 +46 81 3240 2563 3917 13.6 10.8 16.4 809 612 1006 18.2 13.8 22.6 499 366 632 15.3 11.2 19.4 45945 41789 50101 Lawrence County SD est14_SD.txt 06NOV2015 +46 83 2204 1752 2656 4.3 3.4 5.2 731 552 910 4.9 3.7 6.1 451 329 573 4.2 3.1 5.3 79857 74152 85562 Lincoln County SD est14_SD.txt 06NOV2015 +46 85 953 781 1125 24.9 20.4 29.4 384 306 462 35.1 27.9 42.3 235 178 292 30.7 23.3 38.1 40639 36499 44779 Lyman County SD est14_SD.txt 06NOV2015 +46 87 545 428 662 10.0 7.9 12.1 187 142 232 13.2 10.0 16.4 122 89 155 11.8 8.6 15.0 57741 53228 62254 McCook County SD est14_SD.txt 06NOV2015 +46 89 384 299 469 17.0 13.2 20.8 106 79 133 25.4 19.0 31.8 66 48 84 22.4 16.2 28.6 38469 34520 42418 McPherson County SD est14_SD.txt 06NOV2015 +46 91 540 415 665 12.0 9.2 14.8 166 125 207 18.9 14.2 23.6 106 77 135 17.4 12.6 22.2 50155 45322 54988 Marshall County SD est14_SD.txt 06NOV2015 +46 93 2712 2139 3285 10.4 8.2 12.6 959 726 1192 14.9 11.3 18.5 606 442 770 12.9 9.4 16.4 54771 50861 58681 Meade County SD est14_SD.txt 06NOV2015 +46 95 679 537 821 33.2 26.3 40.1 277 214 340 43.3 33.4 53.2 173 129 217 39.7 29.6 49.8 34237 30708 37766 Mellette County SD est14_SD.txt 06NOV2015 +46 97 280 219 341 12.4 9.7 15.1 80 60 100 15.1 11.4 18.8 52 38 66 12.9 9.5 16.3 49159 44257 54061 Miner County SD est14_SD.txt 06NOV2015 +46 99 20429 18149 22709 11.5 10.2 12.8 6357 5331 7383 14.1 11.8 16.4 3916 3197 4635 12.6 10.3 14.9 55107 52264 57950 Minnehaha County SD est14_SD.txt 06NOV2015 +46 101 772 640 904 12.3 10.2 14.4 234 181 287 14.8 11.4 18.2 151 113 189 13.6 10.2 17.0 53654 48245 59063 Moody County SD est14_SD.txt 06NOV2015 +46 103 14908 12875 16941 14.1 12.2 16.0 5162 4196 6128 20.2 16.4 24.0 3108 2412 3804 17.3 13.4 21.2 48379 45600 51158 Pennington County SD est14_SD.txt 06NOV2015 +46 105 453 361 545 15.2 12.1 18.3 122 93 151 18.7 14.2 23.2 77 56 98 15.6 11.4 19.8 39936 35638 44234 Perkins County SD est14_SD.txt 06NOV2015 +46 107 251 197 305 11.0 8.6 13.4 78 59 97 16.3 12.3 20.3 51 37 65 14.4 10.4 18.4 52758 47465 58051 Potter County SD est14_SD.txt 06NOV2015 +46 109 2074 1669 2479 20.4 16.4 24.4 823 644 1002 28.5 22.3 34.7 525 398 652 26.4 20.0 32.8 45911 42429 49393 Roberts County SD est14_SD.txt 06NOV2015 +46 111 329 261 397 14.7 11.7 17.7 98 74 122 20.9 15.7 26.1 63 46 80 19.5 14.2 24.8 46281 41523 51039 Sanborn County SD est14_SD.txt 06NOV2015 +46 113 7398 6422 8374 52.2 45.3 59.1 2897 2423 3371 53.5 44.8 62.2 1767 1426 2108 47.1 38.0 56.2 27244 24485 30003 Shannon County SD est14_SD.txt 06NOV2015 +46 115 738 575 901 11.7 9.1 14.3 237 178 296 16.7 12.6 20.8 146 106 186 13.9 10.1 17.7 48125 43236 53014 Spink County SD est14_SD.txt 06NOV2015 +46 117 263 204 322 8.8 6.8 10.8 86 65 107 12.3 9.3 15.3 55 40 70 10.4 7.6 13.2 67172 63891 70453 Stanley County SD est14_SD.txt 06NOV2015 +46 119 91 69 113 6.3 4.8 7.8 21 15 27 6.7 4.9 8.5 14 10 18 5.8 4.1 7.5 59879 53636 66122 Sully County SD est14_SD.txt 06NOV2015 +46 121 4671 3938 5404 47.4 40.0 54.8 2103 1689 2517 52.8 42.4 63.2 1266 975 1557 46.9 36.1 57.7 27481 24624 30338 Todd County SD est14_SD.txt 06NOV2015 +46 123 1068 854 1282 19.9 15.9 23.9 342 262 422 27.9 21.4 34.4 217 160 274 24.4 18.0 30.8 40545 36585 44505 Tripp County SD est14_SD.txt 06NOV2015 +46 125 830 679 981 10.2 8.3 12.1 234 180 288 12.3 9.5 15.1 152 113 191 10.8 8.0 13.6 55708 50643 60773 Turner County SD est14_SD.txt 06NOV2015 +46 127 937 719 1155 6.3 4.8 7.8 326 246 406 8.5 6.4 10.6 207 151 263 7.1 5.2 9.0 72041 64821 79261 Union County SD est14_SD.txt 06NOV2015 +46 129 849 672 1026 15.9 12.6 19.2 263 201 325 21.3 16.3 26.3 164 121 207 18.2 13.4 23.0 41831 37658 46004 Walworth County SD est14_SD.txt 06NOV2015 +46 135 2849 2322 3376 13.8 11.2 16.4 772 602 942 16.5 12.9 20.1 459 339 579 13.6 10.1 17.1 47363 42831 51895 Yankton County SD est14_SD.txt 06NOV2015 +46 137 1257 987 1527 44.6 35.0 54.2 491 362 620 48.9 36.1 61.7 283 197 369 34.3 23.9 44.7 32025 29359 34691 Ziebach County SD est14_SD.txt 06NOV2015 diff --git a/PovertyInfo/support/povWA.txt b/PovertyInfo/support/povWA.txt new file mode 100644 index 0000000..77bb19a --- /dev/null +++ b/PovertyInfo/support/povWA.txt @@ -0,0 +1,40 @@ +53 0 913463 895355 931571 13.2 12.9 13.5 275662 265882 285442 17.5 16.9 18.1 180464 171990 188938 16.0 15.2 16.8 61358 60882 61834 85453 80800 90106 19.6 18.5 20.7 Washington WA est14_WA.txt 06NOV2015 +53 1 3598 2947 4249 19.0 15.6 22.4 1816 1477 2155 27.1 22.0 32.2 1152 903 1401 24.7 19.4 30.0 47423 42474 52372 Adams County WA est14_WA.txt 06NOV2015 +53 3 3573 2849 4297 16.3 13.0 19.6 1104 846 1362 24.2 18.5 29.9 723 546 900 21.5 16.2 26.8 44055 39944 48166 Asotin County WA est14_WA.txt 06NOV2015 +53 5 26893 23628 30158 14.6 12.8 16.4 10421 8839 12003 21.3 18.1 24.5 6754 5615 7893 19.0 15.8 22.2 58750 56072 61428 Benton County WA est14_WA.txt 06NOV2015 +53 7 10298 8470 12126 14.0 11.5 16.5 3588 2774 4402 20.2 15.6 24.8 2436 1839 3033 19.2 14.5 23.9 49174 45028 53320 Chelan County WA est14_WA.txt 06NOV2015 +53 9 11518 9848 13188 16.2 13.8 18.6 3267 2671 3863 26.2 21.4 31.0 2025 1593 2457 22.3 17.5 27.1 47185 43543 50827 Clallam County WA est14_WA.txt 06NOV2015 +53 11 44213 38703 49723 9.9 8.7 11.1 15179 12259 18099 13.6 11.0 16.2 10647 8436 12858 12.8 10.2 15.4 61747 60396 63098 Clark County WA est14_WA.txt 06NOV2015 +53 13 607 469 745 15.5 12.0 19.0 190 145 235 25.7 19.6 31.8 130 98 162 22.0 16.6 27.4 45465 41255 49675 Columbia County WA est14_WA.txt 06NOV2015 +53 15 20701 18425 22977 20.6 18.3 22.9 6118 5100 7136 26.8 22.3 31.3 3909 3166 4652 23.1 18.7 27.5 44235 41355 47115 Cowlitz County WA est14_WA.txt 06NOV2015 +53 17 6120 4978 7262 15.5 12.6 18.4 2507 1974 3040 24.4 19.2 29.6 1712 1339 2085 22.7 17.8 27.6 51151 47257 55045 Douglas County WA est14_WA.txt 06NOV2015 +53 19 1700 1392 2008 22.4 18.3 26.5 403 316 490 29.1 22.8 35.4 264 205 323 25.9 20.1 31.7 39992 36038 43946 Ferry County WA est14_WA.txt 06NOV2015 +53 21 14661 12404 16918 17.3 14.6 20.0 7214 6027 8401 24.9 20.8 29.0 4533 3611 5455 22.4 17.8 27.0 55006 51191 58821 Franklin County WA est14_WA.txt 06NOV2015 +53 23 310 240 380 14.2 11.0 17.4 91 70 112 20.7 15.8 25.6 60 45 75 17.4 13.1 21.7 46404 41508 51300 Garfield County WA est14_WA.txt 06NOV2015 +53 25 14508 11796 17220 15.8 12.8 18.8 5766 4441 7091 20.9 16.1 25.7 3918 2983 4853 20.0 15.2 24.8 50388 47611 53165 Grant County WA est14_WA.txt 06NOV2015 +53 27 13322 11257 15387 19.6 16.6 22.6 4146 3376 4916 28.6 23.3 33.9 2760 2199 3321 26.3 21.0 31.6 43205 40965 45445 Grays Harbor County WA est14_WA.txt 06NOV2015 +53 29 7964 6639 9289 10.3 8.6 12.0 2267 1801 2733 15.4 12.2 18.6 1514 1190 1838 14.7 11.6 17.8 59358 55827 62889 Island County WA est14_WA.txt 06NOV2015 +53 31 4183 3445 4921 14.1 11.6 16.6 972 770 1174 24.5 19.4 29.6 643 502 784 21.8 17.0 26.6 50964 46641 55287 Jefferson County WA est14_WA.txt 06NOV2015 +53 33 230750 218081 243419 11.3 10.7 11.9 58351 52757 63945 13.6 12.3 14.9 38527 34470 42584 12.8 11.5 14.1 75738 74417 77059 King County WA est14_WA.txt 06NOV2015 +53 35 27550 23819 31281 11.2 9.7 12.7 7473 6103 8843 14.4 11.8 17.0 4593 3607 5579 12.2 9.6 14.8 61898 59584 64212 Kitsap County WA est14_WA.txt 06NOV2015 +53 37 7459 6329 8589 18.6 15.8 21.4 1410 1105 1715 18.7 14.7 22.7 953 742 1164 17.6 13.7 21.5 48127 44926 51328 Kittitas County WA est14_WA.txt 06NOV2015 +53 39 3029 2365 3693 14.6 11.4 17.8 935 713 1157 22.6 17.2 28.0 641 481 801 20.9 15.7 26.1 49348 44723 53973 Klickitat County WA est14_WA.txt 06NOV2015 +53 41 12695 10463 14927 17.1 14.1 20.1 3912 3075 4749 24.5 19.3 29.7 2600 2017 3183 22.3 17.3 27.3 44243 40710 47776 Lewis County WA est14_WA.txt 06NOV2015 +53 43 1274 1002 1546 12.5 9.8 15.2 392 303 481 17.7 13.7 21.7 269 207 331 15.7 12.1 19.3 49955 45180 54730 Lincoln County WA est14_WA.txt 06NOV2015 +53 45 9040 7636 10444 15.6 13.2 18.0 2660 2093 3227 23.6 18.6 28.6 1805 1406 2204 22.4 17.4 27.4 52313 49305 55321 Mason County WA est14_WA.txt 06NOV2015 +53 47 9427 8024 10830 23.2 19.8 26.6 2969 2411 3527 31.5 25.6 37.4 1992 1578 2406 29.5 23.4 35.6 37782 34745 40819 Okanogan County WA est14_WA.txt 06NOV2015 +53 49 3606 2929 4283 17.8 14.5 21.1 965 775 1155 28.8 23.1 34.5 674 538 810 28.0 22.4 33.6 40189 36441 43937 Pacific County WA est14_WA.txt 06NOV2015 +53 51 2868 2398 3338 22.3 18.6 26.0 842 665 1019 33.1 26.2 40.0 588 463 713 30.2 23.8 36.6 42579 38373 46785 Pend Oreille County WA est14_WA.txt 06NOV2015 +53 53 106432 97890 114974 13.1 12.1 14.1 34165 30111 38219 17.5 15.4 19.6 22439 19462 25416 16.2 14.1 18.3 60397 58946 61848 Pierce County WA est14_WA.txt 06NOV2015 +53 55 2018 1729 2307 12.7 10.9 14.5 437 351 523 19.6 15.7 23.5 290 227 353 16.7 13.1 20.3 54721 50513 58929 San Juan County WA est14_WA.txt 06NOV2015 +53 57 18627 16409 20845 15.7 13.8 17.6 6124 5231 7017 23.2 19.8 26.6 3765 3106 4424 19.8 16.3 23.3 51395 48709 54081 Skagit County WA est14_WA.txt 06NOV2015 +53 59 1421 1099 1743 12.6 9.7 15.5 467 353 581 20.1 15.2 25.0 316 235 397 17.5 13.0 22.0 52673 47473 57873 Skamania County WA est14_WA.txt 06NOV2015 +53 61 73930 66931 80929 9.9 9.0 10.8 22598 19490 25706 13.1 11.3 14.9 14401 12105 16697 11.5 9.7 13.3 71890 70201 73579 Snohomish County WA est14_WA.txt 06NOV2015 +53 63 76910 70461 83359 16.3 14.9 17.7 21892 18858 24926 20.5 17.7 23.3 13976 11760 16192 18.2 15.3 21.1 50083 48190 51976 Spokane County WA est14_WA.txt 06NOV2015 +53 65 8368 7255 9481 19.3 16.7 21.9 2668 2169 3167 28.2 22.9 33.5 1773 1413 2133 24.5 19.5 29.5 43823 40849 46797 Stevens County WA est14_WA.txt 06NOV2015 +53 67 31197 27796 34598 11.9 10.6 13.2 9031 7502 10560 15.6 13.0 18.2 5706 4551 6861 13.7 10.9 16.5 61653 59047 64259 Thurston County WA est14_WA.txt 06NOV2015 +53 69 558 431 685 13.9 10.7 17.1 184 141 227 26.7 20.4 33.0 130 98 162 24.3 18.3 30.3 51022 48377 53667 Wahkiakum County WA est14_WA.txt 06NOV2015 +53 71 8682 7030 10334 15.7 12.7 18.7 2654 2046 3262 20.8 16.0 25.6 1762 1341 2183 19.1 14.6 23.6 49819 46459 53179 Walla Walla County WA est14_WA.txt 06NOV2015 +53 73 31842 28461 35223 15.7 14.0 17.4 7304 6146 8462 17.7 14.9 20.5 4888 4054 5722 16.4 13.6 19.2 53733 51153 56313 Whatcom County WA est14_WA.txt 06NOV2015 +53 75 11567 10634 12500 28.4 26.1 30.7 1181 938 1424 16.7 13.3 20.1 704 529 879 14.6 11.0 18.2 41837 37907 45767 Whitman County WA est14_WA.txt 06NOV2015 +53 77 50044 45009 55079 20.5 18.4 22.6 22000 19457 24543 30.3 26.8 33.8 14492 12596 16388 28.0 24.3 31.7 44342 42101 46583 Yakima County WA est14_WA.txt 06NOV2015 diff --git a/interactive_poverty.py b/interactive_poverty.py new file mode 100644 index 0000000..809a57e --- /dev/null +++ b/interactive_poverty.py @@ -0,0 +1,25 @@ +def get_match(county): + data_file = open('povWA.txt', 'r') + for i, record in enumerate(data_file): + if i > 0: + if county + " County" == record[193:238].strip(): + match = record + data_file.close() + return match + data_file.close() + return None + +def print_county_info(record): + print "In {0}, {1} children ({2}%) are in poverty. The median household income is ${3}.".format(record[193:239].strip(), record[49:57].strip(), record[76:80].strip(), record[133:139].strip()) + +county = raw_input("Enter a county name in Washington (e.g., King), or type `quit` to quit: ").strip().capitalize() + +while county != "Q" and county != "Quit": + record = get_match(county) + + while record is None: + county = raw_input("No match found. Try again, or type `quit` to quit: ").strip().capitalize() + record = get_match(county) + + print_county_info(record) + county = raw_input("Enter another county, or type `quit` to quit: ").strip().capitalize() diff --git a/interactive_poverty.rb b/interactive_poverty.rb new file mode 100644 index 0000000..03b2d8e --- /dev/null +++ b/interactive_poverty.rb @@ -0,0 +1,35 @@ +def get_match(county) + File.open("povWA.txt") do |file| + file.each_with_index do |record, i| + if i > 0 + if county + " County" == record[193..237].strip + match = record + return match + end + end + end + end + return nil +end + +def print_county_info(record) + puts "In #{record[193..237].strip}, #{record[49..56].strip} children (#{record[76..79].strip}%) are in poverty. The median household income is $#{record[133..138].strip}." +end + + +print "Enter a county name in Washington (e.g., King), or type `quit` to quit: " +county = gets.chomp.capitalize + +while county != "Q" && county != "Quit" + record = get_match(county) + + while record.nil? + print "No match found. Try again: " + county = gets.chomp.capitalize + record = get_match(county) + end + + print_county_info(record) + print "Enter another county, or type `quit` to quit: " + county = gets.chomp.capitalize +end diff --git a/povSD.txt b/povSD.txt new file mode 100644 index 0000000..7c6eaac --- /dev/null +++ b/povSD.txt @@ -0,0 +1,67 @@ +46 0 115906 111520 120292 14.1 13.6 14.6 37836 35834 39838 18.4 17.4 19.4 23496 21935 25057 16.1 15.0 17.2 51059 50111 52007 13429 12229 14629 22.7 20.7 24.7 South Dakota SD est14_SD.txt 06NOV2015 +46 3 287 226 348 10.8 8.5 13.1 97 73 121 14.5 11.0 18.0 63 46 80 12.9 9.5 16.3 50896 46912 54880 Aurora County SD est14_SD.txt 06NOV2015 +46 5 2685 2165 3205 15.1 12.2 18.0 989 747 1231 22.0 16.6 27.4 638 462 814 21.3 15.4 27.2 49583 46379 52787 Beadle County SD est14_SD.txt 06NOV2015 +46 7 1182 927 1437 34.8 27.3 42.3 525 401 649 45.5 34.8 56.2 338 253 423 41.1 30.7 51.5 34326 30850 37802 Bennett County SD est14_SD.txt 06NOV2015 +46 9 848 662 1034 15.2 11.9 18.5 229 174 284 18.3 13.9 22.7 150 111 189 16.0 11.9 20.1 47987 43732 52242 Bon Homme County SD est14_SD.txt 06NOV2015 +46 11 4230 3552 4908 14.1 11.8 16.4 747 566 928 11.5 8.7 14.3 469 344 594 10.5 7.7 13.3 52930 48346 57514 Brookings County SD est14_SD.txt 06NOV2015 +46 13 4375 3634 5116 11.8 9.8 13.8 1185 917 1453 13.2 10.2 16.2 728 539 917 11.4 8.4 14.4 53150 48208 58092 Brown County SD est14_SD.txt 06NOV2015 +46 15 769 613 925 14.8 11.8 17.8 249 193 305 19.0 14.7 23.3 154 115 193 16.5 12.3 20.7 47224 42548 51900 Brule County SD est14_SD.txt 06NOV2015 +46 17 841 667 1015 40.7 32.3 49.1 395 302 488 47.5 36.3 58.7 249 184 314 44.6 32.9 56.3 21658 19379 23937 Buffalo County SD est14_SD.txt 06NOV2015 +46 19 1605 1285 1925 15.8 12.7 18.9 558 422 694 22.6 17.1 28.1 365 269 461 20.0 14.7 25.3 41446 37285 45607 Butte County SD est14_SD.txt 06NOV2015 +46 21 129 99 159 9.4 7.2 11.6 21 16 26 9.5 7.1 11.9 15 11 19 8.9 6.5 11.3 49895 44691 55099 Campbell County SD est14_SD.txt 06NOV2015 +46 23 2128 1741 2515 24.0 19.6 28.4 825 634 1016 31.4 24.1 38.7 512 379 645 27.9 20.7 35.1 41395 37566 45224 Charles Mix County SD est14_SD.txt 06NOV2015 +46 25 474 374 574 13.8 10.9 16.7 176 135 217 25.6 19.6 31.6 109 80 138 23.7 17.5 29.9 48024 43064 52984 Clark County SD est14_SD.txt 06NOV2015 +46 27 2941 2514 3368 24.9 21.3 28.5 458 348 568 18.3 13.9 22.7 279 205 353 16.4 12.1 20.7 43453 39509 47397 Clay County SD est14_SD.txt 06NOV2015 +46 29 2848 2246 3450 10.3 8.1 12.5 919 692 1146 13.6 10.2 17.0 576 422 730 12.1 8.9 15.3 52892 47782 58002 Codington County SD est14_SD.txt 06NOV2015 +46 31 1612 1325 1899 38.6 31.7 45.5 650 503 797 45.2 35.0 55.4 408 307 509 39.1 29.4 48.8 31420 28934 33906 Corson County SD est14_SD.txt 06NOV2015 +46 33 876 681 1071 10.7 8.3 13.1 237 177 297 18.7 13.9 23.5 162 118 206 17.3 12.7 21.9 51244 46078 56410 Custer County SD est14_SD.txt 06NOV2015 +46 35 2351 1844 2858 12.3 9.6 15.0 658 499 817 14.7 11.2 18.2 418 308 528 13.0 9.6 16.4 48675 43725 53625 Davison County SD est14_SD.txt 06NOV2015 +46 37 888 729 1047 16.3 13.4 19.2 243 186 300 19.7 15.1 24.3 159 119 199 17.6 13.2 22.0 43305 38690 47920 Day County SD est14_SD.txt 06NOV2015 +46 39 430 343 517 10.1 8.1 12.1 127 95 159 12.8 9.6 16.0 84 61 107 11.2 8.1 14.3 51246 46436 56056 Deuel County SD est14_SD.txt 06NOV2015 +46 41 1535 1238 1832 27.2 21.9 32.5 641 479 803 32.7 24.4 41.0 419 301 537 32.5 23.4 41.6 34936 31499 38373 Dewey County SD est14_SD.txt 06NOV2015 +46 43 330 256 404 11.6 9.0 14.2 94 71 117 14.4 10.8 18.0 60 44 76 12.9 9.4 16.4 49251 44041 54461 Douglas County SD est14_SD.txt 06NOV2015 +46 45 397 307 487 10.5 8.1 12.9 111 83 139 13.9 10.4 17.4 70 51 89 12.0 8.7 15.3 57148 51209 63087 Edmunds County SD est14_SD.txt 06NOV2015 +46 47 1135 926 1344 17.0 13.9 20.1 299 229 369 24.4 18.6 30.2 194 143 245 19.5 14.4 24.6 42007 38058 45956 Fall River County SD est14_SD.txt 06NOV2015 +46 49 288 224 352 13.2 10.2 16.2 82 61 103 21.3 15.7 26.9 52 37 67 20.2 14.5 25.9 46633 41777 51489 Faulk County SD est14_SD.txt 06NOV2015 +46 51 725 559 891 10.0 7.7 12.3 219 166 272 13.5 10.2 16.8 141 102 180 11.7 8.5 14.9 52816 47953 57679 Grant County SD est14_SD.txt 06NOV2015 +46 53 761 598 924 18.3 14.4 22.2 255 192 318 27.0 20.3 33.7 166 121 211 23.5 17.1 29.9 36836 33215 40457 Gregory County SD est14_SD.txt 06NOV2015 +46 55 217 170 264 12.0 9.4 14.6 64 48 80 15.3 11.4 19.2 42 30 54 14.0 10.0 18.0 43699 39049 48349 Haakon County SD est14_SD.txt 06NOV2015 +46 57 607 476 738 10.4 8.1 12.7 238 180 296 12.8 9.7 15.9 156 113 199 12.2 8.9 15.5 53944 49055 58833 Hamlin County SD est14_SD.txt 06NOV2015 +46 59 329 261 397 10.0 7.9 12.1 84 64 104 12.0 9.1 14.9 53 39 67 10.0 7.3 12.7 51201 45889 56513 Hand County SD est14_SD.txt 06NOV2015 +46 61 260 198 322 8.1 6.2 10.0 142 106 178 15.2 11.3 19.1 89 64 114 14.2 10.2 18.2 61945 55975 67915 Hanson County SD est14_SD.txt 06NOV2015 +46 63 137 106 168 11.2 8.6 13.8 38 28 48 14.8 11.0 18.6 25 18 32 15.9 11.4 20.4 49220 44193 54247 Harding County SD est14_SD.txt 06NOV2015 +46 65 1853 1487 2219 11.0 8.8 13.2 616 475 757 14.9 11.5 18.3 375 278 472 12.9 9.6 16.2 58340 53108 63572 Hughes County SD est14_SD.txt 06NOV2015 +46 67 884 695 1073 13.2 10.4 16.0 288 218 358 20.4 15.4 25.4 185 135 235 18.4 13.4 23.4 48879 44412 53346 Hutchinson County SD est14_SD.txt 06NOV2015 +46 69 137 107 167 10.1 7.9 12.3 25 19 31 8.4 6.3 10.5 16 12 20 7.0 5.1 8.9 49184 44123 54245 Hyde County SD est14_SD.txt 06NOV2015 +46 71 1097 874 1320 33.9 27.0 40.8 479 364 594 43.3 32.9 53.7 303 224 382 40.5 29.9 51.1 31922 28664 35180 Jackson County SD est14_SD.txt 06NOV2015 +46 73 283 223 343 14.9 11.8 18.0 74 56 92 18.5 13.9 23.1 46 33 59 16.8 12.2 21.4 48773 43655 53891 Jerauld County SD est14_SD.txt 06NOV2015 +46 75 127 98 156 13.1 10.1 16.1 47 35 59 23.2 17.3 29.1 31 22 40 20.0 14.3 25.7 44876 40072 49680 Jones County SD est14_SD.txt 06NOV2015 +46 77 498 396 600 10.1 8.0 12.2 142 107 177 13.1 9.9 16.3 93 68 118 12.2 8.9 15.5 51837 46873 56801 Kingsbury County SD est14_SD.txt 06NOV2015 +46 79 1102 848 1356 9.5 7.3 11.7 268 200 336 11.4 8.5 14.3 173 125 221 10.3 7.5 13.1 53175 47608 58742 Lake County SD est14_SD.txt 06NOV2015 +46 81 3240 2563 3917 13.6 10.8 16.4 809 612 1006 18.2 13.8 22.6 499 366 632 15.3 11.2 19.4 45945 41789 50101 Lawrence County SD est14_SD.txt 06NOV2015 +46 83 2204 1752 2656 4.3 3.4 5.2 731 552 910 4.9 3.7 6.1 451 329 573 4.2 3.1 5.3 79857 74152 85562 Lincoln County SD est14_SD.txt 06NOV2015 +46 85 953 781 1125 24.9 20.4 29.4 384 306 462 35.1 27.9 42.3 235 178 292 30.7 23.3 38.1 40639 36499 44779 Lyman County SD est14_SD.txt 06NOV2015 +46 87 545 428 662 10.0 7.9 12.1 187 142 232 13.2 10.0 16.4 122 89 155 11.8 8.6 15.0 57741 53228 62254 McCook County SD est14_SD.txt 06NOV2015 +46 89 384 299 469 17.0 13.2 20.8 106 79 133 25.4 19.0 31.8 66 48 84 22.4 16.2 28.6 38469 34520 42418 McPherson County SD est14_SD.txt 06NOV2015 +46 91 540 415 665 12.0 9.2 14.8 166 125 207 18.9 14.2 23.6 106 77 135 17.4 12.6 22.2 50155 45322 54988 Marshall County SD est14_SD.txt 06NOV2015 +46 93 2712 2139 3285 10.4 8.2 12.6 959 726 1192 14.9 11.3 18.5 606 442 770 12.9 9.4 16.4 54771 50861 58681 Meade County SD est14_SD.txt 06NOV2015 +46 95 679 537 821 33.2 26.3 40.1 277 214 340 43.3 33.4 53.2 173 129 217 39.7 29.6 49.8 34237 30708 37766 Mellette County SD est14_SD.txt 06NOV2015 +46 97 280 219 341 12.4 9.7 15.1 80 60 100 15.1 11.4 18.8 52 38 66 12.9 9.5 16.3 49159 44257 54061 Miner County SD est14_SD.txt 06NOV2015 +46 99 20429 18149 22709 11.5 10.2 12.8 6357 5331 7383 14.1 11.8 16.4 3916 3197 4635 12.6 10.3 14.9 55107 52264 57950 Minnehaha County SD est14_SD.txt 06NOV2015 +46 101 772 640 904 12.3 10.2 14.4 234 181 287 14.8 11.4 18.2 151 113 189 13.6 10.2 17.0 53654 48245 59063 Moody County SD est14_SD.txt 06NOV2015 +46 103 14908 12875 16941 14.1 12.2 16.0 5162 4196 6128 20.2 16.4 24.0 3108 2412 3804 17.3 13.4 21.2 48379 45600 51158 Pennington County SD est14_SD.txt 06NOV2015 +46 105 453 361 545 15.2 12.1 18.3 122 93 151 18.7 14.2 23.2 77 56 98 15.6 11.4 19.8 39936 35638 44234 Perkins County SD est14_SD.txt 06NOV2015 +46 107 251 197 305 11.0 8.6 13.4 78 59 97 16.3 12.3 20.3 51 37 65 14.4 10.4 18.4 52758 47465 58051 Potter County SD est14_SD.txt 06NOV2015 +46 109 2074 1669 2479 20.4 16.4 24.4 823 644 1002 28.5 22.3 34.7 525 398 652 26.4 20.0 32.8 45911 42429 49393 Roberts County SD est14_SD.txt 06NOV2015 +46 111 329 261 397 14.7 11.7 17.7 98 74 122 20.9 15.7 26.1 63 46 80 19.5 14.2 24.8 46281 41523 51039 Sanborn County SD est14_SD.txt 06NOV2015 +46 113 7398 6422 8374 52.2 45.3 59.1 2897 2423 3371 53.5 44.8 62.2 1767 1426 2108 47.1 38.0 56.2 27244 24485 30003 Shannon County SD est14_SD.txt 06NOV2015 +46 115 738 575 901 11.7 9.1 14.3 237 178 296 16.7 12.6 20.8 146 106 186 13.9 10.1 17.7 48125 43236 53014 Spink County SD est14_SD.txt 06NOV2015 +46 117 263 204 322 8.8 6.8 10.8 86 65 107 12.3 9.3 15.3 55 40 70 10.4 7.6 13.2 67172 63891 70453 Stanley County SD est14_SD.txt 06NOV2015 +46 119 91 69 113 6.3 4.8 7.8 21 15 27 6.7 4.9 8.5 14 10 18 5.8 4.1 7.5 59879 53636 66122 Sully County SD est14_SD.txt 06NOV2015 +46 121 4671 3938 5404 47.4 40.0 54.8 2103 1689 2517 52.8 42.4 63.2 1266 975 1557 46.9 36.1 57.7 27481 24624 30338 Todd County SD est14_SD.txt 06NOV2015 +46 123 1068 854 1282 19.9 15.9 23.9 342 262 422 27.9 21.4 34.4 217 160 274 24.4 18.0 30.8 40545 36585 44505 Tripp County SD est14_SD.txt 06NOV2015 +46 125 830 679 981 10.2 8.3 12.1 234 180 288 12.3 9.5 15.1 152 113 191 10.8 8.0 13.6 55708 50643 60773 Turner County SD est14_SD.txt 06NOV2015 +46 127 937 719 1155 6.3 4.8 7.8 326 246 406 8.5 6.4 10.6 207 151 263 7.1 5.2 9.0 72041 64821 79261 Union County SD est14_SD.txt 06NOV2015 +46 129 849 672 1026 15.9 12.6 19.2 263 201 325 21.3 16.3 26.3 164 121 207 18.2 13.4 23.0 41831 37658 46004 Walworth County SD est14_SD.txt 06NOV2015 +46 135 2849 2322 3376 13.8 11.2 16.4 772 602 942 16.5 12.9 20.1 459 339 579 13.6 10.1 17.1 47363 42831 51895 Yankton County SD est14_SD.txt 06NOV2015 +46 137 1257 987 1527 44.6 35.0 54.2 491 362 620 48.9 36.1 61.7 283 197 369 34.3 23.9 44.7 32025 29359 34691 Ziebach County SD est14_SD.txt 06NOV2015 diff --git a/povWA.txt b/povWA.txt new file mode 100644 index 0000000..77bb19a --- /dev/null +++ b/povWA.txt @@ -0,0 +1,40 @@ +53 0 913463 895355 931571 13.2 12.9 13.5 275662 265882 285442 17.5 16.9 18.1 180464 171990 188938 16.0 15.2 16.8 61358 60882 61834 85453 80800 90106 19.6 18.5 20.7 Washington WA est14_WA.txt 06NOV2015 +53 1 3598 2947 4249 19.0 15.6 22.4 1816 1477 2155 27.1 22.0 32.2 1152 903 1401 24.7 19.4 30.0 47423 42474 52372 Adams County WA est14_WA.txt 06NOV2015 +53 3 3573 2849 4297 16.3 13.0 19.6 1104 846 1362 24.2 18.5 29.9 723 546 900 21.5 16.2 26.8 44055 39944 48166 Asotin County WA est14_WA.txt 06NOV2015 +53 5 26893 23628 30158 14.6 12.8 16.4 10421 8839 12003 21.3 18.1 24.5 6754 5615 7893 19.0 15.8 22.2 58750 56072 61428 Benton County WA est14_WA.txt 06NOV2015 +53 7 10298 8470 12126 14.0 11.5 16.5 3588 2774 4402 20.2 15.6 24.8 2436 1839 3033 19.2 14.5 23.9 49174 45028 53320 Chelan County WA est14_WA.txt 06NOV2015 +53 9 11518 9848 13188 16.2 13.8 18.6 3267 2671 3863 26.2 21.4 31.0 2025 1593 2457 22.3 17.5 27.1 47185 43543 50827 Clallam County WA est14_WA.txt 06NOV2015 +53 11 44213 38703 49723 9.9 8.7 11.1 15179 12259 18099 13.6 11.0 16.2 10647 8436 12858 12.8 10.2 15.4 61747 60396 63098 Clark County WA est14_WA.txt 06NOV2015 +53 13 607 469 745 15.5 12.0 19.0 190 145 235 25.7 19.6 31.8 130 98 162 22.0 16.6 27.4 45465 41255 49675 Columbia County WA est14_WA.txt 06NOV2015 +53 15 20701 18425 22977 20.6 18.3 22.9 6118 5100 7136 26.8 22.3 31.3 3909 3166 4652 23.1 18.7 27.5 44235 41355 47115 Cowlitz County WA est14_WA.txt 06NOV2015 +53 17 6120 4978 7262 15.5 12.6 18.4 2507 1974 3040 24.4 19.2 29.6 1712 1339 2085 22.7 17.8 27.6 51151 47257 55045 Douglas County WA est14_WA.txt 06NOV2015 +53 19 1700 1392 2008 22.4 18.3 26.5 403 316 490 29.1 22.8 35.4 264 205 323 25.9 20.1 31.7 39992 36038 43946 Ferry County WA est14_WA.txt 06NOV2015 +53 21 14661 12404 16918 17.3 14.6 20.0 7214 6027 8401 24.9 20.8 29.0 4533 3611 5455 22.4 17.8 27.0 55006 51191 58821 Franklin County WA est14_WA.txt 06NOV2015 +53 23 310 240 380 14.2 11.0 17.4 91 70 112 20.7 15.8 25.6 60 45 75 17.4 13.1 21.7 46404 41508 51300 Garfield County WA est14_WA.txt 06NOV2015 +53 25 14508 11796 17220 15.8 12.8 18.8 5766 4441 7091 20.9 16.1 25.7 3918 2983 4853 20.0 15.2 24.8 50388 47611 53165 Grant County WA est14_WA.txt 06NOV2015 +53 27 13322 11257 15387 19.6 16.6 22.6 4146 3376 4916 28.6 23.3 33.9 2760 2199 3321 26.3 21.0 31.6 43205 40965 45445 Grays Harbor County WA est14_WA.txt 06NOV2015 +53 29 7964 6639 9289 10.3 8.6 12.0 2267 1801 2733 15.4 12.2 18.6 1514 1190 1838 14.7 11.6 17.8 59358 55827 62889 Island County WA est14_WA.txt 06NOV2015 +53 31 4183 3445 4921 14.1 11.6 16.6 972 770 1174 24.5 19.4 29.6 643 502 784 21.8 17.0 26.6 50964 46641 55287 Jefferson County WA est14_WA.txt 06NOV2015 +53 33 230750 218081 243419 11.3 10.7 11.9 58351 52757 63945 13.6 12.3 14.9 38527 34470 42584 12.8 11.5 14.1 75738 74417 77059 King County WA est14_WA.txt 06NOV2015 +53 35 27550 23819 31281 11.2 9.7 12.7 7473 6103 8843 14.4 11.8 17.0 4593 3607 5579 12.2 9.6 14.8 61898 59584 64212 Kitsap County WA est14_WA.txt 06NOV2015 +53 37 7459 6329 8589 18.6 15.8 21.4 1410 1105 1715 18.7 14.7 22.7 953 742 1164 17.6 13.7 21.5 48127 44926 51328 Kittitas County WA est14_WA.txt 06NOV2015 +53 39 3029 2365 3693 14.6 11.4 17.8 935 713 1157 22.6 17.2 28.0 641 481 801 20.9 15.7 26.1 49348 44723 53973 Klickitat County WA est14_WA.txt 06NOV2015 +53 41 12695 10463 14927 17.1 14.1 20.1 3912 3075 4749 24.5 19.3 29.7 2600 2017 3183 22.3 17.3 27.3 44243 40710 47776 Lewis County WA est14_WA.txt 06NOV2015 +53 43 1274 1002 1546 12.5 9.8 15.2 392 303 481 17.7 13.7 21.7 269 207 331 15.7 12.1 19.3 49955 45180 54730 Lincoln County WA est14_WA.txt 06NOV2015 +53 45 9040 7636 10444 15.6 13.2 18.0 2660 2093 3227 23.6 18.6 28.6 1805 1406 2204 22.4 17.4 27.4 52313 49305 55321 Mason County WA est14_WA.txt 06NOV2015 +53 47 9427 8024 10830 23.2 19.8 26.6 2969 2411 3527 31.5 25.6 37.4 1992 1578 2406 29.5 23.4 35.6 37782 34745 40819 Okanogan County WA est14_WA.txt 06NOV2015 +53 49 3606 2929 4283 17.8 14.5 21.1 965 775 1155 28.8 23.1 34.5 674 538 810 28.0 22.4 33.6 40189 36441 43937 Pacific County WA est14_WA.txt 06NOV2015 +53 51 2868 2398 3338 22.3 18.6 26.0 842 665 1019 33.1 26.2 40.0 588 463 713 30.2 23.8 36.6 42579 38373 46785 Pend Oreille County WA est14_WA.txt 06NOV2015 +53 53 106432 97890 114974 13.1 12.1 14.1 34165 30111 38219 17.5 15.4 19.6 22439 19462 25416 16.2 14.1 18.3 60397 58946 61848 Pierce County WA est14_WA.txt 06NOV2015 +53 55 2018 1729 2307 12.7 10.9 14.5 437 351 523 19.6 15.7 23.5 290 227 353 16.7 13.1 20.3 54721 50513 58929 San Juan County WA est14_WA.txt 06NOV2015 +53 57 18627 16409 20845 15.7 13.8 17.6 6124 5231 7017 23.2 19.8 26.6 3765 3106 4424 19.8 16.3 23.3 51395 48709 54081 Skagit County WA est14_WA.txt 06NOV2015 +53 59 1421 1099 1743 12.6 9.7 15.5 467 353 581 20.1 15.2 25.0 316 235 397 17.5 13.0 22.0 52673 47473 57873 Skamania County WA est14_WA.txt 06NOV2015 +53 61 73930 66931 80929 9.9 9.0 10.8 22598 19490 25706 13.1 11.3 14.9 14401 12105 16697 11.5 9.7 13.3 71890 70201 73579 Snohomish County WA est14_WA.txt 06NOV2015 +53 63 76910 70461 83359 16.3 14.9 17.7 21892 18858 24926 20.5 17.7 23.3 13976 11760 16192 18.2 15.3 21.1 50083 48190 51976 Spokane County WA est14_WA.txt 06NOV2015 +53 65 8368 7255 9481 19.3 16.7 21.9 2668 2169 3167 28.2 22.9 33.5 1773 1413 2133 24.5 19.5 29.5 43823 40849 46797 Stevens County WA est14_WA.txt 06NOV2015 +53 67 31197 27796 34598 11.9 10.6 13.2 9031 7502 10560 15.6 13.0 18.2 5706 4551 6861 13.7 10.9 16.5 61653 59047 64259 Thurston County WA est14_WA.txt 06NOV2015 +53 69 558 431 685 13.9 10.7 17.1 184 141 227 26.7 20.4 33.0 130 98 162 24.3 18.3 30.3 51022 48377 53667 Wahkiakum County WA est14_WA.txt 06NOV2015 +53 71 8682 7030 10334 15.7 12.7 18.7 2654 2046 3262 20.8 16.0 25.6 1762 1341 2183 19.1 14.6 23.6 49819 46459 53179 Walla Walla County WA est14_WA.txt 06NOV2015 +53 73 31842 28461 35223 15.7 14.0 17.4 7304 6146 8462 17.7 14.9 20.5 4888 4054 5722 16.4 13.6 19.2 53733 51153 56313 Whatcom County WA est14_WA.txt 06NOV2015 +53 75 11567 10634 12500 28.4 26.1 30.7 1181 938 1424 16.7 13.3 20.1 704 529 879 14.6 11.0 18.2 41837 37907 45767 Whitman County WA est14_WA.txt 06NOV2015 +53 77 50044 45009 55079 20.5 18.4 22.6 22000 19457 24543 30.3 26.8 33.8 14492 12596 16388 28.0 24.3 31.7 44342 42101 46583 Yakima County WA est14_WA.txt 06NOV2015 diff --git a/poverty_info.py b/poverty_info.py new file mode 100644 index 0000000..5315ff3 --- /dev/null +++ b/poverty_info.py @@ -0,0 +1,51 @@ +STATE_FILES = {"Washington": "povWA.txt", "South Dakota": "povSD.txt"} + +def get_minimum_child_poverty_record(state): + data_file = open(STATE_FILES[state], 'r') + current_min = None + min_county_record = None + + for i, record in enumerate(data_file): + if i > 0: + if current_min is None: + current_min = float(record[76:80]) + if float(record[76:80]) < current_min: + current_min = float(record[76:80]) + min_county_record = record + + data_file.close() + return min_county_record + + +def get_maximum_child_poverty_record(state): + data_file = open(STATE_FILES[state], 'r') + current_max = None + max_county_record = None + + for i, record in enumerate(data_file): + if i > 0: + if current_max is None: + current_max = float(record[76:80]) + if float(record[76:80]) > current_max: + current_max = float(record[76:80]) + max_county_record = record + + data_file.close() + return max_county_record + +print get_minimum_child_poverty_record("Washington") +print get_maximum_child_poverty_record("Washington") +print get_minimum_child_poverty_record("South Dakota") +print get_maximum_child_poverty_record("South Dakota") + + +def print_child_poverty_info(state): + min_county_record = get_minimum_child_poverty_record(state) + max_county_record = get_maximum_child_poverty_record(state) + + print "In {0}:".format(state) + print "The county with the lowest percentage of children in poverty is {0}. In that county, {1} children ({2}%) are in poverty. The median household income is ${3}.".format(min_county_record[193:239].strip(), min_county_record[49:57].strip(), min_county_record[76:80].strip(), min_county_record[133:139].strip()) + print "The county with the highest percentage of children in poverty is {0}. In that county, {1} children ({2}%) are in poverty. The median household income is ${3}.".format(max_county_record[193:239].strip(), max_county_record[49:57].strip(), max_county_record[76:80].strip(), max_county_record[133:139].strip()) + +print_child_poverty_info("Washington") +print_child_poverty_info("South Dakota") diff --git a/poverty_info.rb b/poverty_info.rb new file mode 100644 index 0000000..448adaf --- /dev/null +++ b/poverty_info.rb @@ -0,0 +1,49 @@ +STATE_FILES = { "Washington" => "povWA.txt", "South Dakota" => "povSD.txt"} + +def get_minimum_child_poverty_record(state) + File.open(STATE_FILES[state]) do |file| + current_min = nil + min_county_record = nil + file.each_with_index do |record, i| + if i > 0 # skip the header row + current_min ||= record[76..79].to_f + min_county_record ||= record + if record[76..79].to_f < current_min + current_min = record[76..79].to_f + min_county_record = record + end + end + end + return min_county_record + end +end + +def get_maximum_child_poverty_record(state) + File.open(STATE_FILES[state]) do |file| + current_max = nil + max_county_record = nil + file.each_with_index do |record, i| + if i > 0 # skip the header row + current_max ||= record[76..79].to_f + max_county_record ||= record + if record[76..79].to_f > current_max + current_max = record[76..79].to_f + max_county_record = record + end + end + end + return max_county_record + end +end + +def print_child_poverty_info(state) + min_county_record = get_minimum_child_poverty_record(state) + max_county_record = get_maximum_child_poverty_record(state) + + puts "In #{state}:" + puts "The county with the lowest percentage of children in poverty is #{min_county_record[193..237].strip}. In that county, #{min_county_record[49..56].strip} children (#{min_county_record[76..79].strip}%) are in poverty. The median household income is $#{min_county_record[133..138].strip}." + puts "The county with the highest percentage of children in poverty is #{max_county_record[193..237].strip}. In that county, #{max_county_record[49..56].strip} children (#{max_county_record[76..79].strip}%) are in poverty. The median household income is $#{max_county_record[133..138].strip}." +end + +print_child_poverty_info("Washington") +print_child_poverty_info("South Dakota")