how to convert table resulted from pre-built layout model to csv in Power Automate

51 Views Asked by At

I have a Local PDF document that contains various structure of tables (meaning that it's not a static structure table and I can't predict what does the table look like) and I need to do document processing to extract the tables from the PDF file in power automate, so I used the layout model service from document intelligence, this is details of the model: Microsoft pre-built layout model and to use this model via Power automate, I need to do Rest API call, this is my flow look like:

1- Get file content using path action (from file system)

2- POST HTTP request to call layout model

3- GET HTTP request to get result from layout model

4- parse JSON action to parse the output from GET HTTP request

so, this model returns JSON response with the extracted table in this structure:

 "tables": [
                {
                    "rowCount": 1,
                    "columnCount": 2,
                    "cells": [
                        {
                            "kind": "columnHeader",
                            "rowIndex": 0,
                            "columnIndex": 0,
                            "content": "Name",
                            "boundingRegions": [],
                            "spans": []
                        },
                        {
                            "kind": "columnHeader",
                            "rowIndex": 0,
                            "columnIndex": 1,
                            "content": "Age",
                            "boundingRegions": [],
                            "spans": []
                        },
                       {
                            "rowIndex": 1,
                            "columnIndex": 0,
                            "content": "Muhammed",
                            "boundingRegions": []
                      },
                       {
                            "rowIndex": 1,
                            "columnIndex": 1,
                            "content": "15",
                            "boundingRegions": []
                      }
                        }
                          ]
                            ]

the cell with "kind" columnHeader is a header cell, and the cell without "kind" key is a row cell. I need to convert the structure of table above into CSV in Power automate.

0

There are 0 best solutions below