Converting CSV to JSON with Index value

Hi I want to convert my CSV data into JSON format however the JSON file is input for TPOT AI Fabric model which accepts JSON in a specific format such as:
{“Mango”:[5],“Orange”:[3],“Banana”:[4],“Grapes”:[6]}

Where as I can get CSV to JSON data in a format of :
{“Mango”:“5”,“Orange”:“3”,“Banana”:“4”,“Grapes”:“6”} using few custom Datatable to JSON activities.

Any suggestion on how can I achieve {“Mango”:[5],“Orange”:[3],“Banana”:[4],“Grapes”:[6]} from csv ?

The square brackets represent an array in the JSON file.
Therefore you need to guide your CSV-> JSON converter to interpret the values as single element array.

Cheers

Hi @J0ska, Thanks for the suggestion however, I don’t have a custom activity built at my end. I was referring to the ones available in the market.

Would you help with the code if any ?

Could you disclose how your CSV file looks like?

Cheers

Have a look at the attached
image

CSVtoJSON.xaml (6.2 KB)

Cheers

1 Like

Hi @J0ska Thank you so much for the workflow how ever it isn’t working for me. I have attached csv with the sample could you please create one for that.
SampleCSV.txt (89 Bytes)

I have converted my csv to txt as forum doesn’t support uploading csv files. however structure remains same as displayed.

How exactly should look like the JSON output for your sample CSV?
Do you want it like column name: column value?

Cheers

My problem has been resolved. With the workflow that you shared, I re-engineered it to match my requirement. That’s a very big help. Thanks a ton.

:+1:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.