How can I send a dataframe that consists of thousands of rows to API lemmatization webpage using this code anyone can help me
import json
import http.client
text = df[reviews]
conn = http.client.HTTPSConnection("farasa-api.qcri.org")
payload = "{\"text\":\"%s\"}"% text
payload = payload.encode('utf-8')
headers = { 'content-type': "application/json", 'cache-control': "no-cache", }
conn.request("POST", "/msa/webapi/lemma", payload, headers)
res = conn.getresponse()
data = res.read().decode('utf-8')
data_dict = json.loads(data)
I try to convert csv file to json file and send it to the api but still doesn't work and appear this type of error:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)`
this is what I try to do :
df_json= json.loads(df['review'].to_json(orient='records'))
import json
import http.client
text = df_json
conn = http.client.HTTPSConnection("farasa-api.qcri.org")
payload = "{\"text\":\"%s\"}"% text
payload = payload.encode('utf-8')
headers = { 'content-type': "application/json", 'cache-control': "no-cache", }
conn.request("POST", "/msa/webapi/lemma", payload, headers)
res = conn.getresponse()
data = res.read().decode('utf-8')
data_dict = json.loads(data)