On one hand we have this Pandas Dataframe:
import pandas as pd
df = {"EventName":{"0":"Event234","1":"Event235","2":"Event236"},"EventType":{"0":"TypeA","1":"TypeA","2":"TypeB"},"Data1":{"0":"Data266276","1":"Data266277","2":"Data266278"},"Data2":{"0":"Data432562","1":"Data432563","2":"Data432564"}}
df = pd.DataFrame(df)
print(df)
Returning this:
EventName EventType Data1 Data2
0 Event234 TypeA Data266276 Data432562
1 Event235 TypeA Data266277 Data432563
2 Event236 TypeB Data266278 Data432564
and on the other we have the following function, which sends a post request:
import time
import requests
# Test post url calls
# https://stackoverflow.com/questions/5725430/http-test-server-that-accepts-get-post-calls
AlertURL = "http://httpbin.org/anything"
def alert(msg):
nowdt = time.strftime("%m/%d/%Y %H:%M:%S")
payload = {"msg": str(nowdt)+", "+msg}
response = requests.post(AlertURL, payload)
print(response.text)
alert(df.EventName+" "+df.EventType+" "+df.Data1+" "+df.Data2)
The last line is sending one (1) request with all dataframe rows.
And we want to send one request per dataframe row (three in this case), with a 2 secs delay between them.
How do we do it?