[PyDelhi] how to run for loop in xlsv file

Gora Mohanty gora at mimirtech.com
Wed Dec 2 01:52:26 EST 2015


On 2 December 2015 at 06:13, Shreya Agarwal <shreya2105 at gmail.com> wrote:
>
> Hi,
>
> I have a excel on US airports, I need to get their zip codes in the adjacent column. Using Google geocoding, I could read their zip codes individually. But now I need to run the FOR loop to read all the entries. My excel file has only 1600 rows with names of Airports in a single column.
>
> This is my code:
>
> data = get_data("/Users/shreyaagarwal/Desktop/Airport and zipcodes.xlsx") import json print(json.dumps(data))
>
> for element in row:
>
>      g= geocoder.google(element)
>
>      print (g.postal)
>
> This code reads until 5 rows and then stops This is result: None None None None 54015 None
>
> Which is not correct! Please help. I need to get the zip codes adjacent to the airports in the excel. Is it possible?

You need to ask better questions if you expect people to help you. The
code that you shared:
* Will not work as it stands: row is not defined, geocoder is not imported, etc.
* There is a magic function called get_data which we have no idea
about, but which is likely to be where the problem lies.

What is "row"? What is its length: Maybe it only has 5 entries, maybe
geocoder is throwing an exception. We have no basis on which to
proceed.

Regards,
Gora


More information about the Ncr-Python.in mailing list