Power Automate create CSV table from JSON

Loading

Requirement: Create CSV file from JSON using Power Automate flow

In Power Automate, select the Manually triggered Flow, then click on Next step.

Select Initialize variable action, then provide the variable name, and type as a string.

Next, initialize another variable to store JSON data, so click on the Next step and select Initialize variable action. Then provide the variable name, type as a string, and in value above JSON code.

Code:
{

  "base": "EUR",
  "date": "2021-09-16",
  "rates": {
    "MYN": 24.1678,
    "HRF": 356.500528,
    "MYR": 5.880332
  }
}

Now parse the above code, for that click on the next step and select Parse JSON action. Then in the Content field select the JSON variable from dynamic content. Now generate the schema

Schema:
{
    "type": "object",
    "properties": {
        "base": {
            "type": "string"
        },
        "date": {
            "type": "string"
        },
        "rates": {
            "type": "object",
            "properties": {
                "MYN": {
                    "type": "number"
                },
                "HRF": {
                    "type": "number"
                },
                "MYR": {
                    "type": "number"
                }
            }
        }
    }
}

Now append the header to the CSV table, so click on the Next step and select Append string variable action, then provide the variable name as CSVData, and in value is:

In the next step, add the row for MYN, so click on the Next step and select Append the string variable. Then provide the variable name, and in value is :

Now add the row to the CSV table for HRF, so click on the Next step and select Append to a string variable. Then provide the variable name as CSV data, and write the value.

Now add another row, so click on the next step and select Append to a string variable, then provide the variable name and add the value like below.

Now create a CSV file in the SharePoint library, so click on the Next step and select Create file action. Then provide the site address, folder path, file name with CSV extension and provide the file content.

Now click on Run flow, then go to SharePoint list, the excel data csv file is added.

Click on excel file the output is displayed.

Leave a Reply

Your email address will not be published. Required fields are marked *