Hi,
i have the following Issue:
I get an CSV String as Response of an HTTP Request.
I am not sure how to cast it properly to a Dictionary in UiPath.
As a solution i am relying at the moment on a small python script. But this is not a good solution since i would always need to have python installed somewhere.
Does anyone knows how to do this in UiPath:
import json
import csv
from io import StringIO
def csv_to_dict(response):
# Decode the response to UTF-8
# respContent = response.decode('utf-8')
# Cast the Decoded Response to String
csvText = StringIO(response)
# Read out the CSV
reader = csv.reader(csvText, delimiter=',')
# Create a Helper Object
listObj = {}
#Cycle through all result entries and put them into the list
for num, row in enumerate(reader):
listObj[num] = row
# create the result dict
result = {}
# fill the result Dict
for i in range(len(listObj[0])):
result[listObj[0][i]] = listObj[1][i]
# Return the Result Dict
return str(result)