fips_lookup 0.3.0 → 0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,6 @@ PR,72,001,Adjuntas Municipio,85584,02416094,Vegas Abajo barrio,Z1,N
15
15
  PR,72,001,Adjuntas Municipio,85627,02416095,Vegas Arriba barrio,Z1,N
16
16
  PR,72,001,Adjuntas Municipio,87949,02416110,Yahuecas barrio,Z1,N
17
17
  PR,72,001,Adjuntas Municipio,88250,02416113,Yayales barrio,Z1,N
18
- PR,72,003,Aguada Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
19
18
  PR,72,003,Aguada Municipio,00659,02415089,Aguada barrio-pueblo,Z1,N
20
19
  PR,72,003,Aguada Municipio,04185,02415134,Asomante barrio,Z1,N
21
20
  PR,72,003,Aguada Municipio,04400,02415136,Atalaya barrio,Z1,N
@@ -34,7 +33,6 @@ PR,72,003,Aguada Municipio,51098,02415644,Marías barrio,Z1,N
34
33
  PR,72,003,Aguada Municipio,56215,02415719,Naranjo barrio,Z1,N
35
34
  PR,72,003,Aguada Municipio,61719,02415780,Piedras Blancas barrio,Z1,N
36
35
  PR,72,003,Aguada Municipio,70921,02415929,Río Grande barrio,Z1,N
37
- PR,72,005,Aguadilla Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
38
36
  PR,72,005,Aguadilla Municipio,00530,02415087,Aguacate barrio,Z1,N
39
37
  PR,72,005,Aguadilla Municipio,00788,02415090,Aguadilla barrio-pueblo,Z1,N
40
38
  PR,72,005,Aguadilla Municipio,03626,02415129,Arenales barrio,Z1,N
@@ -70,7 +68,6 @@ PR,72,009,Aibonito Municipio,45895,02415590,Llanos barrio,Z1,N
70
68
  PR,72,009,Aibonito Municipio,60042,02415759,Pasto barrio,Z1,N
71
69
  PR,72,009,Aibonito Municipio,62536,02415789,Plata barrio,Z1,N
72
70
  PR,72,009,Aibonito Municipio,71867,02415944,Robles barrio,Z1,N
73
- PR,72,011,Añasco Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
74
71
  PR,72,011,Añasco Municipio,02637,02415115,Añasco barrio-pueblo,Z1,N
75
72
  PR,72,011,Añasco Municipio,02723,02415113,Añasco Abajo barrio,Z1,N
76
73
  PR,72,011,Añasco Municipio,02766,02415114,Añasco Arriba barrio,Z1,N
@@ -94,7 +91,6 @@ PR,72,011,Añasco Municipio,62665,02415792,Playa barrio,Z1,N
94
91
  PR,72,011,Añasco Municipio,67567,02415883,Quebrada Larga barrio,Z1,N
95
92
  PR,72,011,Añasco Municipio,70147,02415913,Río Arriba barrio,Z1,N
96
93
  PR,72,011,Añasco Municipio,70534,02415926,Río Cañas barrio,Z1,N
97
- PR,72,013,Arecibo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
98
94
  PR,72,013,Arecibo Municipio,03411,02415124,Arecibo barrio-pueblo,Z1,N
99
95
  PR,72,013,Arecibo Municipio,03540,02415126,Arenalejos barrio,Z1,N
100
96
  PR,72,013,Arecibo Municipio,04056,02415133,Arrozal barrio,Z1,N
@@ -114,14 +110,12 @@ PR,72,013,Arecibo Municipio,70190,02415914,Río Arriba barrio,Z1,N
114
110
  PR,72,013,Arecibo Municipio,73759,02415966,Sabana Hoyos barrio,Z1,N
115
111
  PR,72,013,Arecibo Municipio,78704,02416019,Santana barrio,Z1,N
116
112
  PR,72,013,Arecibo Municipio,81757,02416052,Tanamá barrio,Z1,N
117
- PR,72,015,Arroyo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
118
113
  PR,72,015,Arroyo Municipio,02809,02415116,Ancones barrio,Z1,N
119
114
  PR,72,015,Arroyo Municipio,03970,02415132,Arroyo barrio-pueblo,Z1,N
120
115
  PR,72,015,Arroyo Municipio,31748,02415454,Guásimas barrio,Z1,N
121
116
  PR,72,015,Arroyo Municipio,58408,02415746,Palmas barrio,Z1,N
122
117
  PR,72,015,Arroyo Municipio,62192,02415786,Pitahaya barrio,Z1,N
123
118
  PR,72,015,Arroyo Municipio,88164,02416112,Yaurel barrio,Z1,N
124
- PR,72,017,Barceloneta Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
125
119
  PR,72,017,Barceloneta Municipio,05389,02415151,Barceloneta barrio-pueblo,Z1,N
126
120
  PR,72,017,Barceloneta Municipio,29039,02415418,Florida Afuera barrio,Z1,N
127
121
  PR,72,017,Barceloneta Municipio,30415,02415432,Garrochales barrio,Z1,N
@@ -146,7 +140,6 @@ PR,72,021,Bayamón Municipio,53162,02415677,Minillas barrio,Z1,N
146
140
  PR,72,021,Bayamón Municipio,56774,02415727,Nuevo barrio,Z1,N
147
141
  PR,72,021,Bayamón Municipio,57763,02415738,Pájaros barrio,Z1,N
148
142
  PR,72,021,Bayamón Municipio,78790,02416014,Santa Olaya barrio,Z1,N
149
- PR,72,023,Cabo Rojo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
150
143
  PR,72,023,Cabo Rojo Municipio,04787,02415145,Bajura barrio,Z1,N
151
144
  PR,72,023,Cabo Rojo Municipio,08012,02415179,Boquerón barrio,Z1,N
152
145
  PR,72,023,Cabo Rojo Municipio,09818,02415198,Cabo Rojo barrio-pueblo,Z1,N
@@ -167,7 +160,6 @@ PR,72,025,Caguas Municipio,75651,02415987,San Antonio barrio,Z1,N
167
160
  PR,72,025,Caguas Municipio,77371,02416007,San Salvador barrio,Z1,N
168
161
  PR,72,025,Caguas Municipio,82918,02416067,Tomás de Castro barrio,Z1,N
169
162
  PR,72,025,Caguas Municipio,83950,02416079,Turabo barrio,Z1,N
170
- PR,72,027,Camuy Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
171
163
  PR,72,027,Camuy Municipio,00100,02415082,Abra Honda barrio,Z1,N
172
164
  PR,72,027,Camuy Municipio,11968,02415230,Camuy barrio-pueblo,Z1,N
173
165
  PR,72,027,Camuy Municipio,12011,02415229,Camuy Arriba barrio,Z1,N
@@ -187,7 +179,6 @@ PR,72,029,Canóvanas Municipio,22202,02415027,Cubuy barrio,Z1,N
187
179
  PR,72,029,Canóvanas Municipio,33812,02415486,Hato Puerco barrio,Z1,N
188
180
  PR,72,029,Canóvanas Municipio,46669,02415597,Lomas barrio,Z1,N
189
181
  PR,72,029,Canóvanas Municipio,83047,02416070,Torrecilla Alta barrio,Z1,N
190
- PR,72,031,Carolina Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
191
182
  PR,72,031,Carolina Municipio,05819,02415155,Barrazas barrio,Z1,N
192
183
  PR,72,031,Carolina Municipio,09150,02415508,Buena Vista barrio,Z1,N
193
184
  PR,72,031,Carolina Municipio,09947,02415201,Cacao barrio,Z1,N
@@ -225,7 +216,6 @@ PR,72,035,Cayey Municipio,69459,02415903,Rincón barrio,Z1,N
225
216
  PR,72,035,Cayey Municipio,80854,02416040,Sumido barrio,Z1,N
226
217
  PR,72,035,Cayey Municipio,82746,02416065,Toíta barrio,Z1,N
227
218
  PR,72,035,Cayey Municipio,85498,02416096,Vegas barrio,Z1,N
228
- PR,72,037,Ceiba Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
229
219
  PR,72,037,Ceiba Municipio,15967,02414953,Ceiba barrio-pueblo,Z1,N
230
220
  PR,72,037,Ceiba Municipio,17644,02414971,Chupacallos barrio,Z1,N
231
221
  PR,72,037,Ceiba Municipio,23019,02415040,Daguao barrio,Z1,N
@@ -296,7 +286,6 @@ PR,72,049,Culebra Municipio,29426,02415421,Fraile barrio,Z1,N
296
286
  PR,72,049,Culebra Municipio,63396,02415797,Playa Sardinas I barrio,Z1,N
297
287
  PR,72,049,Culebra Municipio,63439,02415798,Playa Sardinas II barrio,Z1,N
298
288
  PR,72,049,Culebra Municipio,76382,02415996,San Isidro barrio,Z1,N
299
- PR,72,051,Dorado Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
300
289
  PR,72,051,Dorado Municipio,24051,02415053,Dorado barrio-pueblo,Z1,N
301
290
  PR,72,051,Dorado Municipio,27448,02415406,Espinosa barrio,Z1,N
302
291
  PR,72,051,Dorado Municipio,34758,02415498,Higuillar barrio,Z1,N
@@ -313,7 +302,6 @@ PR,72,053,Fajardo Municipio,67868,02415887,Quebrada Vueltas barrio,Z1,N
313
302
  PR,72,053,Fajardo Municipio,70233,02415915,Río Arriba barrio,Z1,N
314
303
  PR,72,053,Fajardo Municipio,79779,02416027,Sardinera barrio,Z1,N
315
304
  PR,72,054,Florida Municipio,28996,02415417,Florida Adentro barrio,Z1,N
316
- PR,72,055,Guánica Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
317
305
  PR,72,055,Guánica Municipio,03454,02415125,Arena barrio,Z1,N
318
306
  PR,72,055,Guánica Municipio,12785,02415244,Caño barrio,Z1,N
319
307
  PR,72,055,Guánica Municipio,14032,02415262,Carenero barrio,Z1,N
@@ -322,7 +310,6 @@ PR,72,055,Guánica Municipio,26760,02415398,Ensenada barrio,Z1,N
322
310
  PR,72,055,Guánica Municipio,31232,02415446,Guánica barrio-pueblo,Z1,N
323
311
  PR,72,055,Guánica Municipio,54022,02415692,Montalva barrio,Z1,N
324
312
  PR,72,055,Guánica Municipio,81112,02416042,Susúa Baja barrio,Z1,N
325
- PR,72,057,Guayama Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
326
313
  PR,72,057,Guayama Municipio,01691,02415100,Algarrobo barrio,Z1,N
327
314
  PR,72,057,Guayama Municipio,10549,02415210,Caimital barrio,Z1,N
328
315
  PR,72,057,Guayama Municipio,14075,02415263,Carite barrio,Z1,N
@@ -333,7 +320,6 @@ PR,72,057,Guayama Municipio,38714,02415549,Jobos barrio,Z1,N
333
320
  PR,72,057,Guayama Municipio,48217,02415606,Machete barrio,Z1,N
334
321
  PR,72,057,Guayama Municipio,58494,02415748,Palmas barrio,Z1,N
335
322
  PR,72,057,Guayama Municipio,64256,02415808,Pozo Hondo barrio,Z1,N
336
- PR,72,059,Guayanilla Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
337
323
  PR,72,059,Guayanilla Municipio,05905,02415157,Barrero barrio,Z1,N
338
324
  PR,72,059,Guayanilla Municipio,07840,02415176,Boca barrio,Z1,N
339
325
  PR,72,059,Guayanilla Municipio,15795,02415284,Cedro barrio,Z1,N
@@ -371,7 +357,6 @@ PR,72,063,Gurabo Municipio,51786,02415659,Masa barrio,Z1,N
371
357
  PR,72,063,Gurabo Municipio,56473,02415724,Navarro barrio,Z1,N
372
358
  PR,72,063,Gurabo Municipio,67524,02415882,Quebrada Infierno barrio,Z1,N
373
359
  PR,72,063,Gurabo Municipio,69545,02415905,Rincón barrio,Z1,N
374
- PR,72,065,Hatillo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
375
360
  PR,72,065,Hatillo Municipio,01347,02415095,Aibonito barrio,Z1,N
376
361
  PR,72,065,Hatillo Municipio,07066,02415167,Bayaney barrio,Z1,N
377
362
  PR,72,065,Hatillo Municipio,09216,02415190,Buena Vista barrio,Z1,N
@@ -388,7 +373,6 @@ PR,72,067,Hormigueros Municipio,35075,02415505,Hormigueros barrio,Z1,N
388
373
  PR,72,067,Hormigueros Municipio,35102,02415506,Hormigueros barrio-pueblo,Z1,N
389
374
  PR,72,067,Hormigueros Municipio,37768,02415539,Jaguitas barrio,Z1,N
390
375
  PR,72,067,Hormigueros Municipio,45035,02415580,Lavadero barrio,Z1,N
391
- PR,72,069,Humacao Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
392
376
  PR,72,069,Humacao Municipio,03239,02415122,Antón Ruíz barrio,Z1,N
393
377
  PR,72,069,Humacao Municipio,09302,02415191,Buena Vista barrio,Z1,N
394
378
  PR,72,069,Humacao Municipio,12570,02415240,Candelero Abajo barrio,Z1,N
@@ -402,7 +386,6 @@ PR,72,069,Humacao Municipio,50883,02415642,Mariana barrio,Z1,N
402
386
  PR,72,069,Humacao Municipio,66535,02415861,Punta Santiago barrio,Z1,N
403
387
  PR,72,069,Humacao Municipio,69975,02415910,Río Abajo barrio,Z1,N
404
388
  PR,72,069,Humacao Municipio,81800,02416053,Tejas barrio,Z1,N
405
- PR,72,071,Isabela Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
406
389
  PR,72,071,Isabela Municipio,03669,02415127,Arenales Altos barrio,Z1,N
407
390
  PR,72,071,Isabela Municipio,03712,02415128,Arenales Bajos barrio,Z1,N
408
391
  PR,72,071,Isabela Municipio,04805,02415146,Bajura barrio,Z1,N
@@ -428,7 +411,6 @@ PR,72,073,Jayuya Municipio,71007,02415930,Río Grande barrio,Z1,N
428
411
  PR,72,073,Jayuya Municipio,74748,02415976,Saliente barrio,Z1,N
429
412
  PR,72,073,Jayuya Municipio,85670,02416098,Veguitas barrio,Z1,N
430
413
  PR,72,073,Jayuya Municipio,88465,02416116,Zamas barrio,Z1,N
431
- PR,72,075,Juana Díaz Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
432
414
  PR,72,075,Juana Díaz Municipio,02551,02415112,Amuelas barrio,Z1,N
433
415
  PR,72,075,Juana Díaz Municipio,10979,02415219,Callabo barrio,Z1,N
434
416
  PR,72,075,Juana Díaz Municipio,13903,02415258,Capitanejo barrio,Z1,N
@@ -453,7 +435,6 @@ PR,72,077,Juncos Municipio,45723,02415586,Lirios barrio,Z1,N
453
435
  PR,72,077,Juncos Municipio,49679,02415627,Mamey barrio,Z1,N
454
436
  PR,72,077,Juncos Municipio,84810,02416088,Valenciano Abajo barrio,Z1,N
455
437
  PR,72,077,Juncos Municipio,84853,02416089,Valenciano Arriba barrio,Z1,N
456
- PR,72,079,Lajas Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
457
438
  PR,72,079,Lajas Municipio,12398,02415236,Candelaria barrio,Z1,N
458
439
  PR,72,079,Lajas Municipio,21041,02415011,Costa barrio,Z1,N
459
440
  PR,72,079,Lajas Municipio,40993,02415567,Lajas barrio,Z1,N
@@ -502,21 +483,18 @@ PR,72,085,Las Piedras Municipio,44433,02415579,Las Piedras barrio-pueblo,Z1,N
502
483
  PR,72,085,Las Piedras Municipio,54710,02415701,Montones barrio,Z1,N
503
484
  PR,72,085,Las Piedras Municipio,66793,02415864,Quebrada Arenas barrio,Z1,N
504
485
  PR,72,085,Las Piedras Municipio,81843,02416054,Tejas barrio,Z1,N
505
- PR,72,087,Loíza Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
506
486
  PR,72,087,Loíza Municipio,13043,02415246,Canóvanas barrio,Z1,N
507
487
  PR,72,087,Loíza Municipio,46411,02415595,Loíza barrio-pueblo,Z1,N
508
488
  PR,72,087,Loíza Municipio,52732,02415671,Medianía Alta barrio,Z1,N
509
489
  PR,72,087,Loíza Municipio,52775,02415672,Medianía Baja barrio,Z1,N
510
490
  PR,72,087,Loíza Municipio,83090,02416071,Torrecilla Alta barrio,Z1,N
511
491
  PR,72,087,Loíza Municipio,83133,02416072,Torrecilla Baja barrio,Z1,N
512
- PR,72,089,Luquillo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
513
492
  PR,72,089,Luquillo Municipio,39316,02415554,Juan Martín barrio,Z1,N
514
493
  PR,72,089,Luquillo Municipio,47830,02415602,Luquillo barrio-pueblo,Z1,N
515
494
  PR,72,089,Luquillo Municipio,49980,02415632,Mameyes I barrio,Z1,N
516
495
  PR,72,089,Luquillo Municipio,51872,02415661,Mata de Plátano barrio,Z1,N
517
496
  PR,72,089,Luquillo Municipio,62364,02415787,Pitahaya barrio,Z1,N
518
497
  PR,72,089,Luquillo Municipio,73071,02415959,Sabana barrio,Z1,N
519
- PR,72,091,Manatí Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
520
498
  PR,72,091,Manatí Municipio,04873,02415143,Bajura Adentro barrio,Z1,N
521
499
  PR,72,091,Manatí Municipio,04916,02415144,Bajura Afuera barrio,Z1,N
522
500
  PR,72,091,Manatí Municipio,21342,02415015,Coto Norte barrio,Z1,N
@@ -533,7 +511,6 @@ PR,72,093,Maricao Municipio,36156,02415516,Indiera Fría barrio,Z1,N
533
511
  PR,72,093,Maricao Municipio,51313,02415649,Maricao barrio-pueblo,Z1,N
534
512
  PR,72,093,Maricao Municipio,51399,02415647,Maricao Afuera barrio,Z1,N
535
513
  PR,72,093,Maricao Municipio,54753,02415702,Montoso barrio,Z1,N
536
- PR,72,095,Maunabo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
537
514
  PR,72,095,Maunabo Municipio,11108,02415222,Calzada barrio,Z1,N
538
515
  PR,72,095,Maunabo Municipio,26545,02415394,Emajagua barrio,Z1,N
539
516
  PR,72,095,Maunabo Municipio,45766,02415587,Lizas barrio,Z1,N
@@ -544,7 +521,6 @@ PR,72,095,Maunabo Municipio,59182,02415751,Palo Seco barrio,Z1,N
544
521
  PR,72,095,Maunabo Municipio,66836,02415865,Quebrada Arenas barrio,Z1,N
545
522
  PR,72,095,Maunabo Municipio,81370,02416046,Talante barrio,Z1,N
546
523
  PR,72,095,Maunabo Municipio,83798,02487485,Tumbao barrio,Z1,N
547
- PR,72,097,Mayagüez Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
548
524
  PR,72,097,Mayagüez Municipio,01820,02415103,Algarrobos barrio,Z1,N
549
525
  PR,72,097,Mayagüez Municipio,06464,02415161,Bateyes barrio,Z1,N
550
526
  PR,72,097,Mayagüez Municipio,31103,02415445,Guanajibo barrio,Z1,N
@@ -592,7 +568,6 @@ PR,72,101,Morovis Municipio,76984,02416002,San Lorenzo barrio,Z1,N
592
568
  PR,72,101,Morovis Municipio,83219,02416073,Torrecillas barrio,Z1,N
593
569
  PR,72,101,Morovis Municipio,83993,02416081,Unibón barrio,Z1,N
594
570
  PR,72,101,Morovis Municipio,84638,02416086,Vaga barrio,Z1,N
595
- PR,72,103,Naguabo Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
596
571
  PR,72,103,Naguabo Municipio,23105,02415041,Daguao barrio,Z1,N
597
572
  PR,72,103,Naguabo Municipio,24438,02415059,Duque barrio,Z1,N
598
573
  PR,72,103,Naguabo Municipio,35489,02415509,Húcares barrio,Z1,N
@@ -628,7 +603,6 @@ PR,72,107,Orocovis Municipio,57376,02415734,Orocovis barrio-pueblo,Z1,N
628
603
  PR,72,107,Orocovis Municipio,60816,02415769,Pellejas barrio,Z1,N
629
604
  PR,72,107,Orocovis Municipio,73114,02415960,Sabana barrio,Z1,N
630
605
  PR,72,107,Orocovis Municipio,75178,02415983,Saltos barrio,Z1,N
631
- PR,72,109,Patillas Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
632
606
  PR,72,109,Patillas Municipio,03282,02415123,Apeadero barrio,Z1,N
633
607
  PR,72,109,Patillas Municipio,04744,02415142,Bajo barrio,Z1,N
634
608
  PR,72,109,Patillas Municipio,10119,02415199,Cacao Alto barrio,Z1,N
@@ -645,7 +619,6 @@ PR,72,109,Patillas Municipio,60515,02415764,Patillas barrio-pueblo,Z1,N
645
619
  PR,72,109,Patillas Municipio,63740,02415800,Pollos barrio,Z1,N
646
620
  PR,72,109,Patillas Municipio,67094,02415871,Quebrada Arriba barrio,Z1,N
647
621
  PR,72,109,Patillas Municipio,71695,02415943,Ríos barrio,Z1,N
648
- PR,72,111,Peñuelas Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
649
622
  PR,72,111,Peñuelas Municipio,05862,02415156,Barreal barrio,Z1,N
650
623
  PR,72,111,Peñuelas Municipio,21127,02415013,Coto barrio,Z1,N
651
624
  PR,72,111,Peñuelas Municipio,22460,02415031,Cuebas barrio,Z1,N
@@ -659,7 +632,6 @@ PR,72,111,Peñuelas Municipio,79607,02416024,Santo Domingo barrio,Z1,N
659
632
  PR,72,111,Peñuelas Municipio,81499,02416047,Tallaboa Alta barrio,Z1,N
660
633
  PR,72,111,Peñuelas Municipio,81585,02416048,Tallaboa Poniente barrio,Z1,N
661
634
  PR,72,111,Peñuelas Municipio,81628,02416049,Tallaboa Saliente barrio,Z1,N
662
- PR,72,113,Ponce Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
663
635
  PR,72,113,Ponce Municipio,03067,02415119,Anón barrio,Z1,N
664
636
  PR,72,113,Ponce Municipio,08786,02415185,Bucaná barrio,Z1,N
665
637
  PR,72,113,Ponce Municipio,12312,02415234,Canas barrio,Z1,N
@@ -691,7 +663,6 @@ PR,72,113,Ponce Municipio,80080,02416030,Sexto barrio,Z1,N
691
663
  PR,72,113,Ponce Municipio,81929,02416056,Tercero barrio,Z1,N
692
664
  PR,72,113,Ponce Municipio,82058,02416059,Tibes barrio,Z1,N
693
665
  PR,72,113,Ponce Municipio,85068,02416090,Vayas barrio,Z1,N
694
- PR,72,115,Quebradillas Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
695
666
  PR,72,115,Quebradillas Municipio,10076,02415202,Cacao barrio,Z1,N
696
667
  PR,72,115,Quebradillas Municipio,17515,02414969,Charcas barrio,Z1,N
697
668
  PR,72,115,Quebradillas Municipio,18934,02414992,Cocos barrio,Z1,N
@@ -700,7 +671,6 @@ PR,72,115,Quebradillas Municipio,68083,02415892,Quebradillas barrio-pueblo,Z1,N
700
671
  PR,72,115,Quebradillas Municipio,75823,02415988,San Antonio barrio,Z1,N
701
672
  PR,72,115,Quebradillas Municipio,76597,02415997,San José barrio,Z1,N
702
673
  PR,72,115,Quebradillas Municipio,81972,02416057,Terranova barrio,Z1,N
703
- PR,72,117,Rincón Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
704
674
  PR,72,117,Rincón Municipio,04443,02415137,Atalaya barrio,Z1,N
705
675
  PR,72,117,Rincón Municipio,05948,02415158,Barrero barrio,Z1,N
706
676
  PR,72,117,Rincón Municipio,11065,02415221,Calvache barrio,Z1,N
@@ -711,7 +681,6 @@ PR,72,117,Rincón Municipio,64686,02415813,Pueblo barrio,Z1,N
711
681
  PR,72,117,Rincón Municipio,66449,02415862,Puntas barrio,Z1,N
712
682
  PR,72,117,Rincón Municipio,69631,02415907,Rincón barrio-pueblo,Z1,N
713
683
  PR,72,117,Rincón Municipio,71093,02415932,Río Grande barrio,Z1,N
714
- PR,72,119,Río Grande Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
715
684
  PR,72,119,Río Grande Municipio,18289,02414981,Ciénaga Alta barrio,Z1,N
716
685
  PR,72,119,Río Grande Municipio,18332,02414982,Ciénaga Baja barrio,Z1,N
717
686
  PR,72,119,Río Grande Municipio,33081,02415473,Guzmán Abajo barrio,Z1,N
@@ -729,7 +698,6 @@ PR,72,121,Sabana Grande Municipio,78747,02416020,Santana barrio,Z1,N
729
698
  PR,72,121,Sabana Grande Municipio,81026,02416044,Susúa barrio,Z1,N
730
699
  PR,72,121,Sabana Grande Municipio,81327,02416045,Tabonuco barrio,Z1,N
731
700
  PR,72,121,Sabana Grande Municipio,83004,02416069,Torre barrio,Z1,N
732
- PR,72,123,Salinas Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
733
701
  PR,72,123,Salinas Municipio,01175,02415093,Aguirre barrio,Z1,N
734
702
  PR,72,123,Salinas Municipio,41681,02415570,Lapa barrio,Z1,N
735
703
  PR,72,123,Salinas Municipio,58537,02415749,Palmas barrio,Z1,N
@@ -755,7 +723,6 @@ PR,72,125,San Germán Municipio,73415,02415962,Sabana Eneas barrio,Z1,N
755
723
  PR,72,125,San Germán Municipio,73673,02415963,Sabana Grande Abajo barrio,Z1,N
756
724
  PR,72,125,San Germán Municipio,76210,02415994,San Germán barrio-pueblo,Z1,N
757
725
  PR,72,125,San Germán Municipio,83821,02416078,Tuna barrio,Z1,N
758
- PR,72,127,San Juan Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
759
726
  PR,72,127,San Juan Municipio,10721,02415212,Caimito barrio,Z1,N
760
727
  PR,72,127,San Juan Municipio,22847,02415037,Cupey barrio,Z1,N
761
728
  PR,72,127,San Juan Municipio,24868,02415061,El Cinco barrio,Z1,N
@@ -809,7 +776,6 @@ PR,72,131,San Sebastián Municipio,71910,02415945,Robles barrio,Z1,N
809
776
  PR,72,131,San Sebastián Municipio,75049,02415982,Salto barrio,Z1,N
810
777
  PR,72,131,San Sebastián Municipio,77543,02416008,San Sebastián barrio-pueblo,Z1,N
811
778
  PR,72,131,San Sebastián Municipio,80424,02416034,Sonador barrio,Z1,N
812
- PR,72,133,Santa Isabel Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
813
779
  PR,72,133,Santa Isabel Municipio,07926,02415177,Boca Velázquez barrio,Z1,N
814
780
  PR,72,133,Santa Isabel Municipio,23492,02415047,Descalabrado barrio,Z1,N
815
781
  PR,72,133,Santa Isabel Municipio,28179,02415411,Felicia 1 barrio,Z1,N
@@ -827,7 +793,6 @@ PR,72,135,Toa Alta Municipio,66965,02415868,Quebrada Arenas barrio,Z1,N
827
793
  PR,72,135,Toa Alta Municipio,67180,02415875,Quebrada Cruz barrio,Z1,N
828
794
  PR,72,135,Toa Alta Municipio,71523,02415938,Río Lajas barrio,Z1,N
829
795
  PR,72,135,Toa Alta Municipio,82531,02416063,Toa Alta barrio-pueblo,Z1,N
830
- PR,72,137,Toa Baja Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
831
796
  PR,72,137,Toa Baja Municipio,12484,02415237,Candelaria barrio,Z1,N
832
797
  PR,72,137,Toa Baja Municipio,52646,02415670,Media Luna barrio,Z1,N
833
798
  PR,72,137,Toa Baja Municipio,59268,02415752,Palo Seco barrio,Z1,N
@@ -865,7 +830,6 @@ PR,72,141,Utuado Municipio,82015,02416058,Tetuán barrio,Z1,N
865
830
  PR,72,141,Utuado Municipio,84552,02416084,Utuado barrio-pueblo,Z1,N
866
831
  PR,72,141,Utuado Municipio,87562,02416106,Viví Abajo barrio,Z1,N
867
832
  PR,72,141,Utuado Municipio,87605,02416107,Viví Arriba barrio,Z1,N
868
- PR,72,143,Vega Alta Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
869
833
  PR,72,143,Vega Alta Municipio,04830,02415147,Bajura barrio,Z1,N
870
834
  PR,72,143,Vega Alta Municipio,12527,02415238,Candelaria barrio,Z1,N
871
835
  PR,72,143,Vega Alta Municipio,18418,02414985,Cienegueta barrio,Z1,N
@@ -874,7 +838,6 @@ PR,72,143,Vega Alta Municipio,51356,02415648,Maricao barrio,Z1,N
874
838
  PR,72,143,Vega Alta Municipio,52388,02415667,Mavilla barrio,Z1,N
875
839
  PR,72,143,Vega Alta Municipio,73157,02415961,Sabana barrio,Z1,N
876
840
  PR,72,143,Vega Alta Municipio,85240,02416091,Vega Alta barrio-pueblo,Z1,N
877
- PR,72,145,Vega Baja Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
878
841
  PR,72,145,Vega Baja Municipio,01734,02415101,Algarrobo barrio,Z1,N
879
842
  PR,72,145,Vega Baja Municipio,02121,02415106,Almirante Norte barrio,Z1,N
880
843
  PR,72,145,Vega Baja Municipio,02164,02415107,Almirante Sur barrio,Z1,N
@@ -889,7 +852,6 @@ PR,72,145,Vega Baja Municipio,70104,02415912,Río Abajo barrio,Z1,N
889
852
  PR,72,145,Vega Baja Municipio,70276,02415916,Río Arriba barrio,Z1,N
890
853
  PR,72,145,Vega Baja Municipio,85369,02416092,Vega Baja barrio-pueblo,Z1,N
891
854
  PR,72,145,Vega Baja Municipio,88379,02416115,Yeguada barrio,Z1,N
892
- PR,72,147,Vieques Municipio,00000,00000000,Municipio subdivision not defined,Z9,F
893
855
  PR,72,147,Vieques Municipio,28953,02415420,Florida barrio,Z1,N
894
856
  PR,72,147,Vieques Municipio,36564,02415519,Isabel II barrio-pueblo,Z1,N
895
857
  PR,72,147,Vieques Municipio,46196,02415594,Llave barrio,Z1,N
@@ -6,7 +6,6 @@ RI,44,003,Kent County,22240,01220085,East Greenwich town,T1,A
6
6
  RI,44,003,Kent County,74300,01220058,Warwick city,C5,F
7
7
  RI,44,003,Kent County,77720,01220059,West Greenwich town,T1,A
8
8
  RI,44,003,Kent County,78440,01220060,West Warwick town,T1,A
9
- RI,44,005,Newport County,00000,00000000,County subdivisions not defined,Z9,F
10
9
  RI,44,005,Newport County,36820,01220061,Jamestown town,T1,A
11
10
  RI,44,005,Newport County,42400,01220062,Little Compton town,T1,A
12
11
  RI,44,005,Newport County,45460,01220063,Middletown town,T1,A
@@ -1,4 +1,3 @@
1
- VI,78,010,St. Croix Island,00000,00000000,Island subdivision not defined,Z9,F
2
1
  VI,78,010,St. Croix Island,04600,01939755,Anna's Hope Village subdistrict,Z5,N
3
2
  VI,78,010,St. Croix Island,20800,01939758,Christiansted subdistrict,Z5,N
4
3
  VI,78,010,St. Croix Island,31600,01939761,East End subdistrict,Z5,N
@@ -8,12 +7,10 @@ VI,78,010,St. Croix Island,62200,01939767,Northwest subdistrict,Z5,N
8
7
  VI,78,010,St. Croix Island,71200,01939768,Sion Farm subdistrict,Z5,N
9
8
  VI,78,010,St. Croix Island,73900,01939769,Southcentral subdistrict,Z5,N
10
9
  VI,78,010,St. Croix Island,75700,01939771,Southwest subdistrict,Z5,N
11
- VI,78,020,St. John Island,00000,00000000,Island subdivision not defined,Z9,F
12
10
  VI,78,020,St. John Island,15400,01939756,Central subdistrict,Z5,N
13
11
  VI,78,020,St. John Island,27100,01939759,Coral Bay subdistrict,Z5,N
14
12
  VI,78,020,St. John Island,28900,01939760,Cruz Bay subdistrict,Z5,N
15
13
  VI,78,020,St. John Island,33400,01939762,East End subdistrict,Z5,N
16
- VI,78,030,St. Thomas Island,00000,00000000,Island subdivision not defined,Z9,F
17
14
  VI,78,030,St. Thomas Island,17200,01939757,Charlotte Amalie subdistrict,Z5,N
18
15
  VI,78,030,St. Thomas Island,34300,01939763,East End subdistrict,Z5,N
19
16
  VI,78,030,St. Thomas Island,61300,01939766,Northside subdistrict,Z5,N
@@ -18,7 +18,6 @@ WI,55,001,Adams County,69275,01584060,Rome town,T1,A
18
18
  WI,55,001,Adams County,76350,01584205,Springville town,T1,A
19
19
  WI,55,001,Adams County,77800,01584236,Strongs Prairie town,T1,A
20
20
  WI,55,001,Adams County,88150,01584462,Wisconsin Dells city,C5,F
21
- WI,55,003,Ashland County,00000,00000000,County subdivisions not defined,Z9,F
22
21
  WI,55,003,Ashland County,00550,01582660,Agenda town,T1,A
23
22
  WI,55,003,Ashland County,03225,01582723,Ashland city,C5,F
24
23
  WI,55,003,Ashland County,03250,01582724,Ashland town,T1,A
@@ -71,7 +70,6 @@ WI,55,005,Barron County,78450,01584251,Sumner town,T1,A
71
70
  WI,55,005,Barron County,81075,01584302,Turtle Lake village,C5,F
72
71
  WI,55,005,Barron County,81100,01584303,Turtle Lake town,T1,A
73
72
  WI,55,005,Barron County,82375,01584325,Vance Creek town,T1,A
74
- WI,55,007,Bayfield County,00000,00000000,County subdivisions not defined,Z9,F
75
73
  WI,55,007,Bayfield County,03225,01582723,Ashland city,C5,F
76
74
  WI,55,007,Bayfield County,04725,01582751,Barksdale town,T1,A
77
75
  WI,55,007,Bayfield County,04750,01582752,Barnes town,T1,A
@@ -451,7 +449,6 @@ WI,55,029,Door County,77875,01584239,Sturgeon Bay city,C5,F
451
449
  WI,55,029,Door County,77900,01584240,Sturgeon Bay town,T1,A
452
450
  WI,55,029,Door County,81525,01584310,Union town,T1,A
453
451
  WI,55,029,Door County,83600,01584352,Washington town,T1,A
454
- WI,55,031,Douglas County,00000,00000000,County subdivisions not defined,Z9,F
455
452
  WI,55,031,Douglas County,01825,01582692,Amnicon town,T1,A
456
453
  WI,55,031,Douglas County,06775,01582794,Bennett town,T1,A
457
454
  WI,55,031,Douglas County,10575,01582879,Brule town,T1,A
@@ -700,7 +697,6 @@ WI,55,049,Iowa County,67875,01584034,Ridgeway village,C5,F
700
697
  WI,55,049,Iowa County,67900,01584035,Ridgeway town,T1,A
701
698
  WI,55,049,Iowa County,83150,01584340,Waldwick town,T1,A
702
699
  WI,55,049,Iowa County,89350,01584490,Wyoming town,T1,A
703
- WI,55,051,Iron County,00000,00000000,County subdivisions not defined,Z9,F
704
700
  WI,55,051,Iron County,01925,01582694,Anderson town,T1,A
705
701
  WI,55,051,Iron County,12525,01582916,Carey town,T1,A
706
702
  WI,55,051,Iron County,31875,01583332,Gurney town,T1,A
@@ -796,7 +792,6 @@ WI,55,057,Juneau County,81725,01584316,Union Center village,C5,F
796
792
  WI,55,057,Juneau County,88150,01584462,Wisconsin Dells city,C5,F
797
793
  WI,55,057,Juneau County,88500,01584470,Wonewoc village,C5,F
798
794
  WI,55,057,Juneau County,88525,01584471,Wonewoc town,T1,A
799
- WI,55,059,Kenosha County,00000,00000000,County subdivisions not defined,Z9,F
800
795
  WI,55,059,Kenosha County,09635,01582859,Brighton town,T1,A
801
796
  WI,55,059,Kenosha County,09800,02646685,Bristol village,C5,F
802
797
  WI,55,059,Kenosha County,28675,01583264,Genoa City village,C5,F
@@ -810,7 +805,6 @@ WI,55,059,Kenosha County,74625,02772244,Somers village,C5,F
810
805
  WI,55,059,Kenosha County,74650,01584173,Somers town,T1,A
811
806
  WI,55,059,Kenosha County,81250,01584304,Twin Lakes village,C5,F
812
807
  WI,55,059,Kenosha County,86500,01584421,Wheatland town,T1,A
813
- WI,55,061,Kewaunee County,00000,00000000,County subdivisions not defined,Z9,F
814
808
  WI,55,061,Kewaunee County,00600,01582661,Ahnapee town,T1,A
815
809
  WI,55,061,Kewaunee County,01000,01582672,Algoma city,C5,F
816
810
  WI,55,061,Kewaunee County,12575,01582917,Carlton town,T1,A
@@ -908,7 +902,6 @@ WI,55,069,Lincoln County,74725,01584176,Somo town,T1,A
908
902
  WI,55,069,Lincoln County,80125,01584284,Tomahawk city,C5,F
909
903
  WI,55,069,Lincoln County,80150,01584285,Tomahawk town,T1,A
910
904
  WI,55,069,Lincoln County,87425,01584445,Wilson town,T1,A
911
- WI,55,071,Manitowoc County,00000,00000000,County subdivisions not defined,Z9,F
912
905
  WI,55,071,Manitowoc County,13237,01582933,Cato town,T1,A
913
906
  WI,55,071,Manitowoc County,13750,01582943,Centerville town,T1,A
914
907
  WI,55,071,Manitowoc County,15400,01582976,Cleveland village,C5,F
@@ -1045,7 +1038,6 @@ WI,55,077,Marquette County,75925,01584194,Springfield town,T1,A
1045
1038
  WI,55,077,Marquette County,85575,01584403,Westfield village,C5,F
1046
1039
  WI,55,077,Marquette County,85600,01584404,Westfield town,T1,A
1047
1040
  WI,55,078,Menominee County,50975,01583694,Menominee town,T1,A
1048
- WI,55,079,Milwaukee County,00000,00000000,County subdivisions not defined,Z9,F
1049
1041
  WI,55,079,Milwaukee County,05450,01582766,Bayside village,C5,F
1050
1042
  WI,55,079,Milwaukee County,10375,01582874,Brown Deer village,C5,F
1051
1043
  WI,55,079,Milwaukee County,17975,01583035,Cudahy city,C5,F
@@ -1101,7 +1093,6 @@ WI,55,081,Monroe County,85150,01584395,Wells town,T1,A
1101
1093
  WI,55,081,Monroe County,87525,01584449,Wilton village,C5,F
1102
1094
  WI,55,081,Monroe County,87550,01584450,Wilton town,T1,A
1103
1095
  WI,55,081,Monroe County,89275,01584487,Wyeville village,C5,F
1104
- WI,55,083,Oconto County,00000,00000000,County subdivisions not defined,Z9,F
1105
1096
  WI,55,083,Oconto County,00175,01582651,Abrams town,T1,A
1106
1097
  WI,55,083,Oconto County,04275,01582741,Bagley town,T1,A
1107
1098
  WI,55,083,Oconto County,09375,01582853,Brazeau town,T1,A
@@ -1186,7 +1177,6 @@ WI,55,087,Outagamie County,72750,01584130,Seymour town,T1,A
1186
1177
  WI,55,087,Outagamie County,73625,01584154,Shiocton village,C5,F
1187
1178
  WI,55,087,Outagamie County,82400,01584326,Vandenbroek town,T1,A
1188
1179
  WI,55,087,Outagamie County,89150,01584484,Wrightstown village,C5,F
1189
- WI,55,089,Ozaukee County,00000,00000000,County subdivisions not defined,Z9,F
1190
1180
  WI,55,089,Ozaukee County,05450,01582766,Bayside village,C5,F
1191
1181
  WI,55,089,Ozaukee County,06150,01582781,Belgium village,C5,F
1192
1182
  WI,55,089,Ozaukee County,06175,01582782,Belgium town,T1,A
@@ -1325,7 +1315,6 @@ WI,55,099,Price County,65325,01583978,Prentice village,C5,F
1325
1315
  WI,55,099,Price County,65350,01583979,Prentice town,T1,A
1326
1316
  WI,55,099,Price County,75525,01584186,Spirit town,T1,A
1327
1317
  WI,55,099,Price County,89100,01584482,Worcester town,T1,A
1328
- WI,55,101,Racine County,00000,00000000,County subdivisions not defined,Z9,F
1329
1318
  WI,55,101,Racine County,11200,01582888,Burlington city,C5,F
1330
1319
  WI,55,101,Racine County,11225,01582889,Burlington town,T1,A
1331
1320
  WI,55,101,Racine County,11950,02397529,Caledonia village,C5,F
@@ -1560,7 +1549,6 @@ WI,55,115,Shawano County,84225,01584370,Waukechon town,T1,A
1560
1549
  WI,55,115,Shawano County,85275,01584396,Wescott town,T1,A
1561
1550
  WI,55,115,Shawano County,88325,01584466,Wittenberg village,C5,F
1562
1551
  WI,55,115,Shawano County,88350,01584467,Wittenberg town,T1,A
1563
- WI,55,117,Sheboygan County,00000,00000000,County subdivisions not defined,Z9,F
1564
1552
  WI,55,117,Sheboygan County,00450,01582658,Adell village,C5,F
1565
1553
  WI,55,117,Sheboygan County,12825,01582920,Cascade village,C5,F
1566
1554
  WI,55,117,Sheboygan County,13475,01582938,Cedar Grove village,C5,F
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+
5
+ # FIPS::County
6
+ module FIPS
7
+ class County
8
+ class << self
9
+ def county_cache
10
+ @county_cache ||= {}
11
+ end
12
+
13
+ def loaded_states
14
+ @loaded_states ||= {}
15
+ end
16
+
17
+ def lookup(**params)
18
+ fips = params.fetch(:fips, nil)
19
+ state = params.fetch(:state, nil)
20
+ county = params.fetch(:county, nil)
21
+
22
+ unless fips.nil? || (fips.is_a?(String) && fips.match?(/\A(?:\d{2}|\d{3}|\d{5})\z/))
23
+ raise ArgumentError, "FIPS input must be a 2, 3, or 5 digit string"
24
+ end
25
+ raise ArgumentError, "State input must be a non-empty string" unless state.nil? || (state.is_a?(String) && !state.strip.empty?)
26
+ raise ArgumentError, "County input must be a non-empty string" unless county.nil? || (county.is_a?(String) && !county.strip.empty?)
27
+ raise ArgumentError, "Lookup requires at least one of fips, state, or county parameters" if fips.nil? && state.nil? && county.nil?
28
+
29
+ state_abbr = determine_state_abbr(fips, state)
30
+ raise ArgumentError, "Could not determine state abbreviation from parameters provided: #{params.inspect}" if state_abbr.nil?
31
+
32
+ ensure_csv_indexed!(state_abbr)
33
+
34
+ if county
35
+ cache_key = "#{state_abbr}:#{county.to_s.strip.downcase}"
36
+ match = county_cache[cache_key]
37
+ return match if match
38
+ end
39
+
40
+ if fips
41
+ case fips.length
42
+ when 3
43
+ full_fips = FIPS::State.abbr_to_fips(state_abbr) + fips
44
+ cache_key = "#{state_abbr}:#{full_fips.to_s.strip}"
45
+ when 5
46
+ cache_key = "#{state_abbr}:#{fips.to_s.strip}"
47
+ end
48
+ match = county_cache[cache_key]
49
+ return match if match
50
+ end
51
+ raise ArgumentError, "Could not identify county with parameters provided: #{params.inspect}"
52
+ end
53
+
54
+ def all(state:)
55
+ raise ArgumentError, "State input must be a non-empty string" unless state.is_a?(String) && !state.strip.empty?
56
+
57
+ state_abbr = FIPS::State.lookup(state: state)[:abbr]
58
+ rows = CSV.read(file_path(state_abbr))
59
+ rows.map { |row| formatted_county(row) }
60
+ end
61
+
62
+ def file_path(state_abbr)
63
+ File.expand_path("../data/county/#{state_abbr.upcase}.csv", __dir__)
64
+ end
65
+
66
+ private
67
+
68
+ def determine_state_abbr(fips, state)
69
+ case fips&.length
70
+ when 2
71
+ FIPS::State.fips_to_abbr(fips)
72
+ when 3
73
+ raise ArgumentError, "A 3-digit FIPS code requires a state for county lookup" if state.nil?
74
+
75
+ FIPS::State.lookup(state: state)[:abbr]
76
+ when 5
77
+ FIPS::State.fips_to_abbr(fips[0..1])
78
+ else
79
+ raise ArgumentError, "State input is required to lookup county information" if state.nil?
80
+
81
+ FIPS::State.lookup(state: state)[:abbr]
82
+ end
83
+ end
84
+
85
+ def ensure_csv_indexed!(state_abbr)
86
+ return if loaded_states[state_abbr]
87
+
88
+ raw_content = CSV.read(file_path(state_abbr))
89
+ raw_content.each do |row|
90
+ row_hash = formatted_county(row)
91
+
92
+ name_key = "#{state_abbr}:#{row_hash[:name].to_s.strip.downcase}"
93
+ county_cache[name_key] = row_hash
94
+ fips_key = "#{state_abbr}:#{row_hash[:fips].to_s.strip}"
95
+ county_cache[fips_key] = row_hash
96
+ end
97
+ loaded_states[state_abbr] = true
98
+ end
99
+
100
+ def formatted_county(row)
101
+ {
102
+ state_abbr: row[0],
103
+ fips: row[1] + row[2],
104
+ gnis: row[4],
105
+ name: row[3],
106
+ class_code: row[5],
107
+ status: row[6]
108
+ }
109
+ end
110
+ end
111
+ end
112
+ end
data/lib/fips/state.rb ADDED
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+
5
+ # FIPS::State
6
+ module FIPS
7
+ class State
8
+ ABBR_CODES = { "AL" => "01", "AK" => "02", "AZ" => "04", "AR" => "05", "CA" => "06", "CO" => "08",
9
+ "CT" => "09", "DE" => "10", "DC" => "11", "FL" => "12", "GA" => "13", "HI" => "15",
10
+ "ID" => "16", "IL" => "17", "IN" => "18", "IA" => "19", "KS" => "20", "KY" => "21",
11
+ "LA" => "22", "ME" => "23", "MD" => "24", "MA" => "25", "MI" => "26", "MN" => "27",
12
+ "MS" => "28", "MO" => "29", "MT" => "30", "NE" => "31", "NV" => "32", "NH" => "33",
13
+ "NJ" => "34", "NM" => "35", "NY" => "36", "NC" => "37", "ND" => "38", "OH" => "39",
14
+ "OK" => "40", "OR" => "41", "PA" => "42", "RI" => "44", "SC" => "45", "SD" => "46",
15
+ "TN" => "47", "TX" => "48", "UT" => "49", "VT" => "50", "VA" => "51", "WA" => "53",
16
+ "WV" => "54", "WI" => "55", "WY" => "56", "AS" => "60", "GU" => "66", "MP" => "69",
17
+ "PR" => "72", "UM" => "74", "VI" => "78" }.freeze
18
+
19
+ class << self
20
+ def abbr_to_fips(abbr)
21
+ ABBR_CODES[abbr&.to_s&.upcase]
22
+ end
23
+
24
+ def fips_to_abbr(fips)
25
+ ABBR_CODES.key(fips&.to_s)
26
+ end
27
+
28
+ def lookup(**params)
29
+ fips = params.fetch(:fips, nil)
30
+ state = params.fetch(:state, nil)
31
+
32
+ state_row = raw_csv.find { |row| row.include?(fips) || row.include?(state) }
33
+
34
+ return formatted_state(state_row) unless state_row.nil?
35
+
36
+ raw_csv.each do |row|
37
+ return formatted_state(row) if row[0] == fips || row[1].casecmp?(state) || row[2].casecmp?(state) || row[3] == state
38
+ end
39
+
40
+ raise ArgumentError, "Could not identify state with parameters provided: #{params.inspect}"
41
+ end
42
+
43
+ def all
44
+ raw_csv.map { |row| formatted_state(row) }
45
+ end
46
+
47
+ def raw_csv
48
+ @raw_csv ||= CSV.read(file_path)
49
+ end
50
+
51
+ private
52
+
53
+ def file_path
54
+ File.expand_path("../data/state.csv", __dir__)
55
+ end
56
+
57
+ def formatted_state(row)
58
+ {
59
+ fips: row[0],
60
+ abbr: row[1],
61
+ name: row[2],
62
+ ansi: row[3]
63
+ }
64
+ end
65
+ end
66
+ end
67
+ end