Python Week 2

name_locations.csv

id,first_name,last_name,Lat,Lon,Address
1,Jose,Campbell,45.95007,-71.9824,41 Grim Avenue
2,Donna,Burke,64.5954,18.6735,51 Esch Court
3,Charles,Harper,55.9,37.55,85 Shoshone Plaza
4,Roger,Williamson,29.81523,107.29496,5 Dwight Park
5,Angela,Foster,18.68703,98.91939,9 Wayridge Point
6,Gloria,Peters,15.28333,-87.55,21 Emmet Lane
7,Joseph,Ortiz,-10.0813,124.4633,94 Annamark Trail
8,Eugene,Watkins,8.25,-80.55,95644 Milwaukee Avenue
9,Joseph,Sanders,19.56856,109.85248,29013 Cambridge Terrace
10,Nicole,Miller,-6.894,112.2949,9628 Blackbird Center
11,Benjamin,Kennedy,-6.8253,111.7393,941 Continental Street
12,Jose,Lee,56.75833,48.47611,34 Di Loreto Plaza
13,Roger,Williamson,28.02871,120.96613,401 Glacier Hill Drive
14,Beverly,Patterson,5.6,27.46667,9 Lake View Parkway
15,Barbara,Chavez,28.26421,120.12558,69 Shoshone Hill
16,Kathy,Hernandez,26.455,110.64167,4 Grover Point
17,Stephen,Price,61.919,25.17011,91348 Utah Hill
18,Jesse,Gibson,-19.45,29.81667,15 Elgar Place
19,Maria,Montgomery,-7.0121,112.4618,81681 Nevada Center
20,Judy,Roberts,23.9825,-99.1881,82490 Karstens Plaza
21,Louis,Mendoza,40.31356,44.40483,7 Menomonie Pass
22,Rachel,Mcdonald,53.90806,-6.80556,9 Tennyson Center
23,Philip,Cook,-23.66607,27.74477,3364 Kenwood Way
24,Ashley,Day,-8.5261,121.9715,5476 Petterle Way
25,Douglas,Gutierrez,53.4122,24.5387,8694 Manitowish Crossing
26,Doris,Garza,50.1164,-122.96946,22030 Vermont Street
27,Ann,Kennedy,-8.99167,125.21972,0615 Bultman Park
28,Sandra,Mitchell,52.2183,6.8958,560 Lakewood Alley
29,Peter,Gordon,49.46603,18.09249,28 Rieder Pass
30,Gerald,Gomez,36.51667,136.56667,82374 Hoffman Parkway
31,Wayne,Peters,9.46694,125.57722,5 Corscot Pass
32,Barbara,Cole,15.5878,119.9455,5488 Lerdahl Avenue
33,Fred,Sanders,30.87066,55.27025,6308 Myrtle Lane
34,Bruce,Webb,55.08392,21.87851,372 Hayes Junction
35,Anthony,Gordon,30.26158,120.48884,1 Prentice Trail
36,Marilyn,Chapman,48.4333,2.15,5 Glendale Park
37,Tammy,Hill,43.12165,133.12347,3336 Caliangt Road
38,Kathleen,Harvey,45.7485,4.8467,27 2nd Drive
39,Carlos,Scott,41.67494,112.91109,7565 Sunnyside Point
40,Philip,Reynolds,35.67528,111.15806,5 3rd Center
41,Elizabeth,Stanley,-39.00158,174.23836,28 Shoshone Trail
42,Todd,Bailey,14.608,-61.0093,9885 Sachs Hill
43,Clarence,Carpenter,-6.698,111.3075,8755 Dottie Plaza
44,Diane,Collins,-10.1594,123.5918,4951 Petterle Street
45,Janice,Morris,59.8828,10.8448,6711 Hoepker Junction
46,Ralph,Lawson,-7.3882,108.1215,14519 Namekagon Plaza
47,Bonnie,Lynch,13.04704,100.92891,96 Loftsgordon Point
48,William,Foster,35.62231,10.75696,6 Bartillon Alley
49,Marie,Campbell,39.0833,-9.4,61 Moland Court
50,Betty,Miller,40.6955,-8.5984,3244 Holmberg Alley
51,Terry,Knight,40.63428,44.22241,53 Corry Point
52,Samuel,Cooper,17.72271,121.44695,87 Russell Junction
53,Phyllis,Hill,27.27412,116.57499,2 Maple Wood Pass
54,Michelle,Williams,17.41567,102.78589,8 Butternut Street
55,Eric,Bennett,29.44593,107.31952,3806 Petterle Parkway
56,Peter,Brooks,46.58064,125.46606,6 Heath Pass
57,Jonathan,Stewart,9.35029,-65.32452,15469 Stuart Pass
58,Juan,Garrett,-12.26667,-74.95,761 Maywood Plaza
59,Sandra,Sullivan,-27.04346,-55.22698,674 Ilene Street
60,Albert,Wallace,32.51888,34.90459,93 Knutson Hill
61,Beverly,Castillo,20.75167,-76.02694,053 Mitchell Circle
62,James,Carpenter,35.92056,14.36639,8 Waywood Court
63,Kimberly,Chavez,5.69472,-76.66111,11 Clyde Gallagher Alley
64,Bobby,Ford,34.40658,109.65203,8 Brickson Park Crossing
65,Keith,Myers,56.32035,160.84541,30566 Farmco Trail
66,Dennis,Dunn,46.20694,16.91694,5 Scofield Pass
67,Charles,Pierce,9.6241,123.0188,99601 Kim Point
68,Cheryl,Bowman,49.20875,37.24848,615 Fairfield Terrace
69,Edward,Fowler,38.9746,-9.2365,9805 Caliangt Hill
70,Steven,Cox,14.29804,44.37795,89270 Bobwhite Center
71,Paula,Lee,4.83916,-75.66726,39 Buena Vista Park
72,Nicole,Hudson,-23.9,-61.85,47 Del Mar Lane
73,Doris,Bailey,40.37907,120.23317,2 Northridge Terrace
74,Donna,Little,30.26936,115.9574,245 Lawn Alley
75,Stephen,Peterson,26.49603,116.39019,778 Truax Junction
76,Terry,Taylor,-30.15,30.08333,87625 Fallview Junction
77,Nicole,Bennett,37.0833,-8.25,2793 Service Street
78,Howard,Dixon,43.84889,43.63278,75 Butternut Parkway
79,Shawn,Ruiz,-10.03778,-76.21528,106 Wayridge Hill
80,Rachel,Reynolds,42.6976,2.8954,4966 Fisk Circle
81,Sarah,Hill,-33.20059,27.11385,13 Vera Park
82,Carolyn,Ray,43.5547,-5.9248,82 Marcy Park
83,Patrick,White,55.3751,13.1569,8228 Ridgeview Junction
84,Beverly,Schmidt,38.2222,-85.6885,7 Bayside Pass
85,Lisa,Williams,29.36709,119.80987,73086 Golf Course Avenue
86,John,Dunn,50.51315,16.57528,23 High Crossing Lane
87,Matthew,Mendoza,45.6125,5.1456,81 Truax Avenue
88,Edward,Day,9.9959,-84.05126,9 Badeau Place
89,Rebecca,Rose,23.41382,114.93293,0095 Mandrake Parkway
90,Justin,Gordon,-5.50308,-45.23693,818 Wayridge Hill
91,Martha,Castillo,28.63552,108.92855,0722 Goodland Court
92,Lawrence,Palmer,30.7474,113.21476,33 Farwell Pass
93,Elizabeth,Edwards,46.1667,1.8667,65 Luster Drive
94,Christine,Wheeler,49.57649,21.86811,4 Elgar Circle
95,Michelle,Bryant,54.8108,29.7086,3484 Basil Parkway
96,Joe,Cooper,44.59267,130.327,296 Hallows Drive
97,Clarence,Howell,13.12972,122.97917,75121 Jackson Alley
98,Wanda,Gibson,-9.83333,-77.65,4412 Bowman Junction
99,Ruth,Simpson,-6.7353,111.4931,75 Magdeline Circle
100,Harold,Fernandez,42.05,-8.5833,75321 Mccormick Drive

main.py

import csv

#Geographic Bounding box of North America(ish)
top = 72.471968 # north lat
left = -168.222656 # west long
right = -47.988281 # east long
bottom =  12.801088 # south lat

#empty list that we will append names to that are located inside the using
people_NA = []

#using the "with" syntax we only open the csv file for as long as we need to
#The name of the csv has to be in quotes, and we open it in a read only state "r"
#using the "as" is assigning the open file to a variable, in this case f
with open("name_locations.csv","r" ) as f:
  
  #create an object that reads the data in
  reader = csv.reader(f)
  next(reader, None) #we want to skip the header row, this little bit does that.
  
  #now we will iterate through the rows
  for row in reader:
    #think of the row as a list, where we can access certain elements of interest using the bracket and
    #index notation we've used in the past
    

    #in this case we want lat and lon, so we will create a variable
    #everything will be read in as a string, so we want to convert it 
    #to a decimal
    lat #access the index of the row where the lat is and convert it to float
    lon #access the index of the row where the lon is and convert it to float
     
    #lets evaulate if this location is within the continental united states using some comparisons
    # and conditional statmements
    
    #create a chained set of comparison evaluators to check 
    #chain comparisons. You're looking for a lat that is between the top and bottom
    # and a lon that is between the left and right (or right and left....)
    if .....:
      
      name = (tuple of data to append)
      
      


print people_NA, len(people_NA)