azurecsvazure-logic-appscsvtojson

Convert CSV to JSON using Azure Logic App


I'm using an Azure Logic App to get Blob contents from my storage account. The Blob-file is in .CSV format. I want to convert the CSV file into JSON.

I'm aware of the third party connectors like Plumsail documents, but they are paid. Is there a no-cost solution to this?

Any help would be greatly appreciated. Thanks!


Solution

  • You can split the content of the csv file using the split method, then store it in an array through traversal, and then append it into a Json string.

    For example, the content of the csv file is

    test1,test2,test3
    testx,testy,testz
    

    You need to split each line first, and then split each line with ,.

    Note that \r\n is not easy to type in logic app, you can write it in Notepad first, and then paste it into ʻExpression`:

    split(body('Get_blob_content_using_path'),'
    ')
    

    enter image description here

    You can refer to this post. Although it is very cumbersome, it still has reference significance.

    =============update==================

    The complete workflow is as follows:

    enter image description here

    enter image description here

    enter image description here

    Note:

    In for each, you need to enable Concurrency Control and set its value to 1, otherwise it will execute in parallel and cause the append operation to be out of order.

    enter image description here