cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
drewbty
Helper II
Helper II

Create html table from csv file

I am using the step Create File From Paginated Report

which creates a CSV file

the output of the CSV file is as below:

 

{
"statusCode": 200,
"headers": {
"Pragma": "no-cache",
"Transfer-Encoding": "chunked",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"RequestId": "27bd1808-fc47-457c-b3b6-b91933d08050",
"Access-Control-Expose-Headers": "RequestId",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"x-ms-apihub-obo": "false",
"Cache-Control": "no-store, must-revalidate, no-cache",
"Date": "Wed, 16 Nov 2022 10:26:49 GMT",
"Content-Type": "text/csv",
"Content-Length": "944082"
},
"body": "ClientID,Username,FirstName,Surname,ClientProfile,Channel,Affiliate\r\n0000,0000,xxxx,xxxx,xxxx,xxxxx,xxxxx\r\0000,0000,xxxx,xxxxx,xxxxx,xxxxx\r\n

 

How do I create a HTML table from this CSV output file?

 

1 ACCEPTED SOLUTION

Accepted Solutions
grantjenkins
Super User
Super User

Ok, new and improved solution without the Apply to each, or having to add the { } to build up each object. Also, much more efficient and not using up your billable actions.

 

Full flow is below. I'll go into each of the actions.

grantjenkins_0-1668673186075.png

 

Compose JSON contains your sample JSON data (including just 6 items in the second record).

grantjenkins_1-1668673245766.png

 

Compose Array uses the following expression. It splits the body by \r\n and skips the first row since that contains our headers and we only want the data.

 

skip(split(outputs('Compose_JSON')?['body'], decodeUriComponent('%0D%0A')), 1)

 

grantjenkins_2-1668673245311.png

 

Filter array just removes the last item (empty items). The expression is just:

 

item()

 

grantjenkins_3-1668673245425.png

 

Select takes in the output from Filter array. It uses the following expressions for each of the fields.

 

split(item(), ',')[0]
split(item(), ',')[1]
split(item(), ',')[2]
split(item(), ',')[3]
split(item(), ',')[4]
split(item(), ',')[5]

//And the last field that could potentially be empty

if(equals(length(split(item(), ',')), 6), '', split(item(), ',')[6])

 

grantjenkins_7-1668673328815.png

 

And finally, we have our Create HTML table which takes in the output from Select.

grantjenkins_0-1668673618124.png

 

After running the flow, we would have the following HTML table.

grantjenkins_9-1668673503118.png

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

View solution in original post

18 REPLIES 18
StretchFredrik
Multi Super User
Multi Super User

Hello!

 

This thread has a solution that should work in your case too:

 

Convert .csv file into an HTML table - Power Platform Community (microsoft.com)

Sundeep_Malik
Multi Super User
Multi Super User

Hey @drewbty 

 

You can use create html table action for this.

But it only accepts array as input.

So, do one thing, create a compose action. In that store the above.

Then make another compose in that write:

createArray(outputs('Compose'))

or if you want the headers, you can write createArray(outputs('Compose').headers)

and if you want only body you can write createArray(outputs('Compose').body)

And then pass this compose in create html table action.

 

This is how the flow looks like:

 

Sundeep_Malik_0-1668596368426.png

 

 

1st Compose:

Contains your above data

Sundeep_Malik_1-1668596399633.png

 

2nd compose:

used compose action and used createArray function inside it on headers.

Sundeep_Malik_2-1668596443228.png

 

3rd Compose:

Passed Outputs of compose 2

Sundeep_Malik_3-1668596474016.png

 

Output:

 

Sundeep_Malik_4-1668596508715.png

 

Or if you want everything in that html action, like headers, body and status code at the same time you will have to go in advance settings of html table action and make the columns manually, other than automatically.

 

If this was the solution, you were looking for you can accept this as a solution and if you liked the explanation, you can give a thumbs up. 🙂

Hi @Sundeep_Malik 

 

Getting the following error when attempting this.

 

Do I have to select the columns manually? How do I access each one if so

drewbty_1-1668599889304.png
drewbty_0-1668599870339.png

 

drewbty
Helper II
Helper II

If just headers are passed in on compose2 I get this 

 

drewbty_0-1668600351095.png

 

Sundeep_Malik
Multi Super User
Multi Super User

@drewbty 

I am seeing that orange arrow for the first time.

@StretchFredrik have you seen the orange arrow before or have any idea about it?

 

@drewbty I think the problem could be with that Power Bi Action can you expand it in run history and post the screenshot here.

 

And also post what you have added in that create html action in edit mode.

I think it just means that retries occured?

 

{"statusCode":200,"headers":{"Pragma":"no-cache","Transfer-Encoding":"chunked","Strict-Transport-Security":"max-age=31536000; includeSubDomains","X-Frame-Options":"deny","X-Content-Type-Options":"nosniff","RequestId":"4d4336f9-8172-4dbe-81c8-dcd2763f5e49","Access-Control-Expose-Headers":"RequestId","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","x-ms-apihub-obo":"false","Cache-Control":"no-store, must-revalidate, no-cache","Date":"Wed, 16 Nov 2022 11:57:22 GMT","Content-Type":"text/csv","Content-Length":"944082"},"body":"ClientID,Username,FirstName,Surname,ClientProfile,Channel,Affiliate\r\nxxxxx,xxxx,xxxx,xxxx,xxxxx\r\n

 

 

I've attached a sample of this first line of output here , and the screenshot below

 

drewbty_1-1668600599169.png

 

grantjenkins
Super User
Super User

What was the final output you were expecting to see?

 

Also, do you have the full JSON as the current JSON you posted isn't complete/valid. There is a missing n after \r\, and there should be 7 columns of data, but the second row only contains 6.

"ClientID,Username,FirstName,Surname,ClientProfile,Channel,Affiliate\r\n0000,0000,xxxx,xxxx,xxxx,xxxxx,xxxxx\r\0000,0000,xxxx,xxxxx,xxxxx,xxxxx\r\n

 

And lastly, will the fields be the same every time? (ClientID,Username,FirstName,Surname,ClientProfile,Channel,Affiliate)


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.

Hi Grant


Expected final output is a html table, final step in the flow is create html table

 

I can't post the full Json as I'd have to just change all values to xxxx for integrity reasons, would take too long ( I thought it was CSV as that's the file output I selected in the flow step) 

 

Assume there is a r\ and n\ in all the right places. Apologies but that was just a typo when I was manually blacking out the field data

 

The row does contain 6 - that's because the final field has no data entry for it. Only the final column field (AffiliateID) can ever be blank

 

Yes the columns will be the same every time

grantjenkins
Super User
Super User

Here's a flow that will hopefully get what you're after. This assumes the only field that could be blank (as you mentioned) is the last field Affiliate.

 

The full flow is below. I'll go into each of the actions.

grantjenkins_0-1668603203735.png

 

Compose JSON contains your sample JSON data (including just 6 items in the second record).

grantjenkins_1-1668603263416.png

 

Compose Array uses the following expression. It splits the body by \r\n and skips the first row since that contains our headers and we only want the data.

skip(split(outputs('Compose_JSON')?['body'], decodeUriComponent('%0D%0A')), 1)

grantjenkins_2-1668603356732.png

 

Filter array just removes the last item (empty items). The expression is just:

item()

grantjenkins_3-1668603411827.png

 

Apply to each iterates over each of the items from Filter array.

grantjenkins_4-1668603443594.png

 

Compose Split uses the following expression to split each of the items by comma. It will give us an array containing each of the items in the current row.

split(items('Apply_to_each'), ',')

grantjenkins_5-1668603516263.png

 

Compose Object builds up an object for each row. The expressions are as follows:

outputs('Compose_Split')[0]
outputs('Compose_Split')[1]
outputs('Compose_Split')[2]
outputs('Compose_Split')[3]
outputs('Compose_Split')[4]
outputs('Compose_Split')[5]

//And the last field that could potentially be emtpy

if(equals(length(outputs('Compose_Split')), 6), '', outputs('Compose_Split')[6])

 

Looking at the raw code using Peek code we see:

{
    "inputs": {
        "Client ID": "@{outputs('Compose_Split')[0]}",
        "Username": "@{outputs('Compose_Split')[1]}",
        "First Name": "@{outputs('Compose_Split')[2]}",
        "Surname": "@{outputs('Compose_Split')[3]}",
        "Client Profile": "@{outputs('Compose_Split')[4]}",
        "Channel": "@{outputs('Compose_Split')[5]}",
        "Affiliate": "@{if(equals(length(outputs('Compose_Split')), 6), '', outputs('Compose_Split')[6])}"
    }
}

grantjenkins_6-1668603784278.png

 

And finally, after the Apply to each, we have our Create HTML table which takes in the output from Compose Object.

outputs('Compose_Object')

grantjenkins_7-1668603863045.png

 

After running the flow, we would have the following HTML table.

grantjenkins_8-1668603909515.png

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
drewbty
Helper II
Helper II


edit

drewbty
Helper II
Helper II

Hi @grantjenkins 

 

Couple of things:

 

Just like to flag first that my first step is Export To File For Paginated Reports and I have selected output type as CSV, not JSON, if this matters to your flow. 

 

The flow started running so here's hoping...

 

Update: 40 mins later and it's still running the 'apply to each' step so I had to cancel. I can see it's not designed for large sets of data which is fine, as there would probably just be a couple of hundred anyway in actuality

 

I updated the Export to File for Paginated Report parameter to just have ~200 rows and it runs through the core parts. 

 

Now, I still get the following error though at the final step - create html table

 

drewbty_0-1668645116619.png

 

I've tried to manually do columns by selecting them with item()?[ColumnName'] (not sure if syntax is right for this data type but worked for me before)

 

No luck however

 

drewbty_0-1668647898619.png

 

 

To highlight something, my Compose Object line looks a little different as I couldn't put curly brackets at the top and bottom as it gave an 'enter a valid json' error. 

 

 

 

My Compose Object sneak peak code looks like this

 

drewbty_3-1668646182863.png

 

 

 

 

 

 

{
    "inputs": "\"ClientID\": \"@{outputs('Compose_Split')[0]}\",\n\"Username\": \"@{outputs('Compose_Split')[1]}\",\n\"FirstName\": \"@{outputs('Compose_Split')[2]}\",\n\"Surname\": \"@{outputs('Compose_Split')[3]}\",\n\"ClientProfile\": \"@{outputs('Compose_Split')[4]}\",\n\"Channel\": \"@{outputs('Compose_Split')[5]}\",\n\"Affiliate\": \"@{if(equals(length(outputs('Compose_Split')), 6), '', outputs('Compose_Split')[6])}\"",
    "metadata": {
        "operationMetadataId": "3e89534f-52a2-414a-8f3b-1bb1dd468193"
    }
}

 

 

 

 

 

 

Unsure if my Compose Object step is actually doing anything, as it shows the input and output the same, just for 1 row

 

drewbty_0-1668646797288.png

 

Is this the expected format?

 

drewbty_1-1668646886148.png

 

 

 

 

 

 

Ajinder31
Continued Contributor
Continued Contributor

Hi @drewbty , It seems to me that we're missing the enclosing the Compose object inside curly brackets. Please check @grantjenkins post compose screenshot brackets highlighted below.

Ajinder31_0-1668661987373.png



--------------------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

drewbty
Helper II
Helper II

As I’ve flagged, that gives a ‘enter a valid json’ error if you attempt to include curly brackets
grantjenkins
Super User
Super User

I'll see if I can get rid of that Apply to each completely. Give me a few hours.


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
grantjenkins
Super User
Super User

Ok, new and improved solution without the Apply to each, or having to add the { } to build up each object. Also, much more efficient and not using up your billable actions.

 

Full flow is below. I'll go into each of the actions.

grantjenkins_0-1668673186075.png

 

Compose JSON contains your sample JSON data (including just 6 items in the second record).

grantjenkins_1-1668673245766.png

 

Compose Array uses the following expression. It splits the body by \r\n and skips the first row since that contains our headers and we only want the data.

 

skip(split(outputs('Compose_JSON')?['body'], decodeUriComponent('%0D%0A')), 1)

 

grantjenkins_2-1668673245311.png

 

Filter array just removes the last item (empty items). The expression is just:

 

item()

 

grantjenkins_3-1668673245425.png

 

Select takes in the output from Filter array. It uses the following expressions for each of the fields.

 

split(item(), ',')[0]
split(item(), ',')[1]
split(item(), ',')[2]
split(item(), ',')[3]
split(item(), ',')[4]
split(item(), ',')[5]

//And the last field that could potentially be empty

if(equals(length(split(item(), ',')), 6), '', split(item(), ',')[6])

 

grantjenkins_7-1668673328815.png

 

And finally, we have our Create HTML table which takes in the output from Select.

grantjenkins_0-1668673618124.png

 

After running the flow, we would have the following HTML table.

grantjenkins_9-1668673503118.png

 


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
drewbty
Helper II
Helper II

@grantjenkins this is next level thanks. Appreciate your help!!

 

Question for you. If I was to apply this across to other reports that might have empty values on other field rows (not always with the final field like with Affiliate here) - is there a way of handling that too?

grantjenkins
Super User
Super User

It would depend on the raw data. At the moment if there is a missing value it just doesn't add it. If there were two missing values and you got 4 out of the 6 values (for example) you might get: xxxx,xxxxx,xxxxx,xxxxx. In this case, how would you know if it was the second value that was missing, or the third, etc.?


----------------------------------------------------------------------
If I've answered your question, please mark the post as Solved.
If you like my response, please consider giving it a Thumbs Up.
drewbty
Helper II
Helper II

@grantjenkins seem to have missed a final comma after blacking out the data

 

If there is a blank on the Affiliate, it would display like this xxxx,xxxxx,xxxxx,xxxx,\r\n

 

If there is a blank on a field row in position2, it would be like xxxxx,,xxxxx,xxxxx

 

In other reports, the only other way I’ve found power automate might output the blanks like this xxxxx,”,xxxx,xxxx

 

So I think the blank inputs appear just 1 of just 2 ways as outputs

a double comma i.e. ,, 

or a comma, single quotation marks, then a comma i.e. ,”,

Helpful resources

Announcements

Exclusive LIVE Community Event: Power Apps Copilot Coffee Chat with Copilot Studio Product Team

It's time for the SECOND Power Apps Copilot Coffee Chat featuring the Copilot Studio product team, which will be held LIVE on April 3, 2024 at 9:30 AM Pacific Daylight Time (PDT).     This is an incredible opportunity to connect with members of the Copilot Studio product team and ask them anything about Copilot Studio. We'll share our special guests with you shortly--but we want to encourage to mark your calendars now because you will not want to miss the conversation.   This live event will give you the unique opportunity to learn more about Copilot Studio plans, where we’ll focus, and get insight into upcoming features. We’re looking forward to hearing from the community, so bring your questions!   TO GET ACCESS TO THIS EXCLUSIVE AMA: Kudo this post to reserve your spot! Reserve your spot now by kudoing this post.  Reservations will be prioritized on when your kudo for the post comes through, so don't wait! Click that "kudo button" today.   Invitations will be sent on April 2nd.Users posting Kudos after April 2nd at 9AM PDT may not receive an invitation but will be able to view the session online after conclusion of the event. Give your "kudo" today and mark your calendars for April 3, 2024 at 9:30 AM PDT and join us for an engaging and informative session!

Tuesday Tip: Unlocking Community Achievements and Earning Badges

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!     THIS WEEK'S TIP: Unlocking Achievements and Earning BadgesAcross the Communities, you'll see badges on users profile that recognize and reward their engagement and contributions. These badges each signify a different achievement--and all of those achievements are available to any Community member! If you're a seasoned pro or just getting started, you too can earn badges for the great work you do. Check out some details on Community badges below--and find out more in the detailed link at the end of the article!       A Diverse Range of Badges to Collect The badges you can earn in the Community cover a wide array of activities, including: Kudos Received: Acknowledges the number of times a user’s post has been appreciated with a “Kudo.”Kudos Given: Highlights the user’s generosity in recognizing others’ contributions.Topics Created: Tracks the number of discussions initiated by a user.Solutions Provided: Celebrates the instances where a user’s response is marked as the correct solution.Reply: Counts the number of times a user has engaged with community discussions.Blog Contributor: Honors those who contribute valuable content and are invited to write for the community blog.       A Community Evolving Together Badges are not only a great way to recognize outstanding contributions of our amazing Community members--they are also a way to continue fostering a collaborative and supportive environment. As you continue to share your knowledge and assist each other these badges serve as a visual representation of your valuable contributions.   Find out more about badges in these Community Support pages in each Community: All About Community Badges - Power Apps CommunityAll About Community Badges - Power Automate CommunityAll About Community Badges - Copilot Studio CommunityAll About Community Badges - Power Pages Community

Tuesday Tips: Powering Up Your Community Profile

TUESDAY TIPS are our way of communicating helpful things we've learned or shared that have helped members of the Community. Whether you're just getting started or you're a seasoned pro, Tuesday Tips will help you know where to go, what to look for, and navigate your way through the ever-growing--and ever-changing--world of the Power Platform Community! We cover basics about the Community, provide a few "insider tips" to make your experience even better, and share best practices gleaned from our most active community members and Super Users.   With so many new Community members joining us each week, we'll also review a few of our "best practices" so you know just "how" the Community works, so make sure to watch the News & Announcements each week for the latest and greatest Tuesday Tips!   This Week's Tip: Power Up Your Profile!  🚀 It's where every Community member gets their start, and it's essential that you keep it updated! Your Community User Profile is how you're able to get messages, post solutions, ask questions--and as you rank up, it's where your badges will appear and how you'll be known when you start blogging in the Community Blog. Your Community User Profile is how the Community knows you--so it's essential that it works the way you need it to! From changing your username to updating contact information, this Knowledge Base Article is your best resource for powering up your profile.     Password Puzzles? No Problem! Find out how to sync your Azure AD password with your community account, ensuring a seamless sign-in. No separate passwords to remember! Job Jumps & Email Swaps Changed jobs? Got a new email? Fear not! You'll find out how to link your shiny new email to your existing community account, keeping your contributions and connections intact. Username Uncertainties Unraveled Picking the perfect username is crucial--and sometimes the original choice you signed up with doesn't fit as well as you may have thought. There's a quick way to request an update here--but remember, your username is your community identity, so choose wisely. "Need Admin Approval" Warning Window? If you see this error message while using the community, don't worry. A simple process will help you get where you need to go. If you still need assistance, find out how to contact your Community Support team. Whatever you're looking for, when it comes to your profile, the Community Account Support Knowledge Base article is your treasure trove of tips as you navigate the nuances of your Community Profile. It’s the ultimate resource for keeping your digital identity in tip-top shape while engaging with the Power Platform Community. So, dive in and power up your profile today!  💪🚀   Community Account Support | Power Apps Community Account Support | Power AutomateCommunity Account Support | Copilot Studio  Community Account Support | Power Pages

Super User of the Month | Chris Piasecki

In our 2nd installment of this new ongoing feature in the Community, we're thrilled to announce that Chris Piasecki is our Super User of the Month for March 2024. If you've been in the Community for a while, we're sure you've seen a comment or marked one of Chris' helpful tips as a solution--he's been a Super User for SEVEN consecutive seasons!   Since authoring his first reply in April 2020 to his most recent achievement organizing the Canadian Power Platform Summit this month, Chris has helped countless Community members with his insights and expertise. In addition to being a Super User, Chris is also a User Group leader, Microsoft MVP, and a featured speaker at the Microsoft Power Platform Conference. His contributions to the new SUIT program, along with his joyous personality and willingness to jump in and help so many members has made Chris a fixture in the Power Platform Community.   When Chris isn't authoring solutions or organizing events, he's actively leading Piasecki Consulting, specializing in solution architecture, integration, DevOps, and more--helping clients discover how to strategize and implement Microsoft's technology platforms. We are grateful for Chris' insightful help in the Community and look forward to even more amazing milestones as he continues to assist so many with his great tips, solutions--always with a smile and a great sense of humor.You can find Chris in the Community and on LinkedIn. Thanks for being such a SUPER user, Chris! 💪 🌠  

Find Out What Makes Super Users So Super

We know many of you visit the Power Platform Communities to ask questions and receive answers. But do you know that many of our best answers and solutions come from Community members who are super active, helping anyone who needs a little help getting unstuck with Business Applications products? We call these dedicated Community members Super Users because they are the real heroes in the Community, willing to jump in whenever they can to help! Maybe you've encountered them yourself and they've solved some of your biggest questions. Have you ever wondered, "Why?"We interviewed several of our Super Users to understand what drives them to help in the Community--and discover the difference it has made in their lives as well! Take a look in our gallery today: What Motivates a Super User? - Power Platform Community (microsoft.com)

March User Group Update: New Groups and Upcoming Events!

  Welcome to this month’s celebration of our Community User Groups and exciting User Group events. We’re thrilled to introduce some brand-new user groups that have recently joined our vibrant community. Plus, we’ve got a lineup of engaging events you won’t want to miss. Let’s jump right in: New User Groups   Sacramento Power Platform GroupANZ Power Platform COE User GroupPower Platform MongoliaPower Platform User Group OmanPower Platform User Group Delta StateMid Michigan Power Platform Upcoming Events  DUG4MFG - Quarterly Meetup - Microsoft Demand PlanningDate: 19 Mar 2024 | 10:30 AM to 12:30 PM Central America Standard TimeDescription: Dive into the world of manufacturing with a focus on Demand Planning. Learn from industry experts and share your insights. Dynamics User Group HoustonDate: 07 Mar 2024 | 11:00 AM to 01:00 PM Central America Standard TimeDescription: Houston, get ready for an immersive session on Dynamics 365 and the Power Platform. Connect with fellow professionals and expand your knowledge. Reading Dynamics 365 & Power Platform User Group (Q1)Date: 05 Mar 2024 | 06:00 PM to 09:00 PM GMT Standard TimeDescription: Join our virtual meetup for insightful discussions, demos, and community updates. Let’s kick off Q1 with a bang! Leaders, Create Your Events!  Leaders of existing User Groups, don’t forget to create your events within the Community platform. By doing so, you’ll enable us to share them in future posts and newsletters. Let’s spread the word and make these gatherings even more impactful! Stay tuned for more updates, inspiring stories, and collaborative opportunities from and for our Community User Groups.   P.S. Have an event or success story to share? Reach out to us – we’d love to feature you!

Users online (6,025)