0

I will begin my question by warning that I am an absolute and complete novice with Python, I am attempting to to create a map with NSF Grant amounts and the Congressional district those grants were received in. In order to do this, I need to first associate those locations with Congressional Districts in California. I've been attempting to use Python for this because there are nearly a thousand active NSF grants in California, and I wanted to avoid doing this by hand.

Anyways, it has been about a week since I began to teach myself a bit of Python. I have managed to create an excel spreadsheet that has all the data I should need. Column A is zipcodes, B is the corresponding Congressional district, D is the value of the grant received, and E is the zipcode within which the grant was received.

A-B and C-D are disconnected right now and I essentially need to have a program that, for example, would take value E2 (90007), find the corresponding zip code in Column A, grab the value in Column B on the same row as the matched zip code in Column A, and lastly write that value from Column B to F2, beside the original zip code that was searched for.

I need to do this for 900+ zip codes in Column E. I have been attempting to use DataNitro to interface with Excel through Python and accomplish this, but I have no idea how to do it. Any suggestions?

  • Have you tried using VLOOKUP? – Ben Lerner Aug 19 '15 at 18:35
  • That looks very promising, how would I go about using that to store the info VLOOKUP finds in the same row within which it found it? – Eric Ralph Aug 19 '15 at 18:57
  • Jk, that was a silly question. New problem is that when I use VLOOKUP to search for a specific zip code, I am required by the syntax of the formula to include the column containing the zip code I am searching for. Thus, rather than finding the instance of that specified zip code in column C, the formula finds the exact same zip code in column A and records the number of the congressional district (column D) that is actually associated with the zip codes in column C. – Eric Ralph Aug 19 '15 at 20:11
  • 1
    Jk again, figured it out myself. Thanks a lot for the suggestion, Ben! – Eric Ralph Aug 19 '15 at 20:28

0 Answers0