Looping a CSV into Query - Python

Hi, Is it possible to loop a file into the variable $pair so it runs for each address in the csv individually. Thanks.

def run_query(query): # A simple function to use requests.post to make the API call.
headers = {‘X-API-KEY’: ‘…’}
variables = {‘pair’: “0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc”}
request = requests.post(‘https://graphql.bitquery.io/’,
json={‘query’: query, ‘variables’: variables}, headers=headers)
if request.status_code == 200:
return request.json()
else:
raise Exception(‘Query failed and return code is {}. {}’.format(request.status_code,
query))

query = “”"
query ($pair: String) {
ethereum {
smartContractEvents(
smartContractAddress: {is: $pair}
smartContractEvent: {is: “Mint”}
options: {limit: 10, desc: “block.height”}
) {
block {
height
}
arguments {
value
argument
}
smartContract {
currency {
symbol
}
}
}
}
}
“”"
result = run_query(query) # Execute the query

can you please elaborate on what you are trying to do

I am trying to run a list of addresses into the ‘pair’ variable in a loop

No, you would have to read a csv place it in the pair variable, you would have to do that on your own.