10-19-2022 12:52 PM - last edited 05-07-2024 11:38 AM
Quickly & Easily Convert Various CSVs to New Excel Tables
Takes in most types of CSV data, dynamically identifies the header names, and creates an Excel table in a new or existing workbook.
No premium, 3rd party, or Office Script actions required. Only standard connectors.
(Works on comma-separated files where any items with in-data commas are surrounded in double quotes “String1, String2” but comma separated arrays with double quotes inside an item may also cause issues.)
For example, here is a CSV I downloaded from a random SharePoint list:
And I did not create any template doc table, & I did not adjust any names. I just selected the CSV file in my OneDrive, then ran the flow to get this output...
(But if you’re just downloading this template, then you will need to change the “Create table” action document library reference to your OneDrive folder instead of the id that is in there by default)
If needed, you should also be able to dynamically change the destination Excel to an existing workbook & worksheet based on other values in your flow. And the CSV data can automatically come from any preceding actions.
If you use something other than the default OneDrive action to get your CSV data, then add the CSV output to the "CSV_Data" field in the "Compose CSV data + Set-up" action.
If your CSV header row with column names is not the 1st row in your CSV, make sure to adjust the "ColumnNamesRow" value in the "Compose CSV data + Set-up" action to match the correct CSV row number.
This template is really just a combination of...
-The CSV to Dataset template with manual column mapping: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-to-Dataset/td-p/1508191
-@RezaDorrani's video on exporting data to an Excel table: https://youtu.be/Kupz71dWYyY
-@Paulie78's video on fast exporting to an Excel table: https://youtu.be/AA-D4lgjR3o
Please 1st try downloading the below zip file & importing the whole flow as described in this post: https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-To-New-Excel-Table/m-p/1891765/highl...
If the standard zip file import method does not work for you, then you can try an alternative Power Apps Solution import method here: Re: CSV To New Excel Table - Page 15 - Power Platform Community (microsoft.com)
Or an alternative clipboard copy & paste import method from these 3 posts
https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-To-New-Excel-Table/m-p/1841481/highl...
https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-To-New-Excel-Table/m-p/1841499/highl...
https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-To-New-Excel-Table/m-p/1841504/highl...
https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-To-New-Excel-Table/m-p/1843986/highl...
Warning. The Groups HTTP connector with access to the graph API calls used for this template may be removed soon. You can vote to ask for this not to be removed here: https://ideas.powerautomate.com/d365community/idea/d51463df-6f0c-ed11-a81b-6045bd7c3e3f
You can also try using a different premium HTTP action to make that final call, like what Matt does here: https://www.matthewdevaney.com/quickly-add-multiple-rows-to-excel-table-in-power-automate/
Version 1.1 of the template flow does just this & uses the PREMIUM Azure HTTP action.
To set up the Azure HTTP action connection, use https://graph.microsoft.com for the url & for the Resource URI:
Version 1.1SP is set up to get the CSV from SharePoint & transfer the new Excel file & new table to SharePoint at the end of the flow.
Thanks for any feedback!
It may be running into some other error & the error response message is not formatted in proper JSON or something.
It’s hard to diagnose if it comes on randomly, but the most recent solution package import CSVToNewExcelTable_x_0_0_x.zip includes a Non Premium version of the flow that, instead of a graph call, uses an Office Script to batch create up to like 18,000 rows of a CSV to the new Excel table. But it does take longer to run.
So if you want to try for something more reliable, are fine with a slower flow, & don’t have CSVs with more than 18,000 rows, then you could try that version instead.