python - Iterating over a csv reader object to call api with requests.get -


i have several hundred companies query api. api url call each in csv file in 1 column in form: http://api.duedil.com/open/search?q={"company name"}&api_key=xxxxxxxxxxxxxx

i've used csv open , read in csv file reader object can't work out how iterate on return details each company e.g.

for row in reader:   requests.get(row) 

running on single url works fine giving json data i'd expect:

r = requests.get(url) 

apologies if bit of trivial seeming question how can iterate on each url in csv reader object feeding requests.get call , store result in file object of sort. thanks

this csv.reader object prints out as:

for row in reader:  print(row)  ['http://api.duedil.com/open/search?q={"parkeon ltd"}&api_key=xxxxxxx '] ['http://api.duedil.com/open/search?q={"m , d foundations , building services ltd"}&api_key=xxxxxxxxx '] ['http://api.duedil.com/open/search?q={"tm lewin"}&api_key=xxxxxx '] ['http://api.duedil.com/open/search?q={"stralfors plc"}&api_key=xxxxxx '] ['http://api.duedil.com/open/search?q={"cpm uk ltd"}&api_key=xxxxx '] 

the csv reader class returns tuple, when there's 1 row. try using:

for row in reader:     requests.get(row[0]) 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -