web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :

CSV to Dataset

takolota1 Profile Picture Posted by takolota1 4,974 Moderator

Template for converting large CSV files to JSON, then sending the data to a table or list.

 

This get data for CSV works even if there are commas in the CSV data. The only requirement is the the CSV file must follow the standard of placing double quotes “ , “ around any item eith in-data commas.

 

Set Up

Go to the bottom of this post & download the CSVToJSON_1_0_0_xx.zip file. Go to the Power Apps home page (https://make.powerapps.com/). Select Solutions on the left-side menu, select Import solution, Browse your files & select the CSVToJSON_1_0_0_xx.zip file you just downloaded. Then select Next & follow the menu prompts to apply or create the required connections for the solution flows.

ImportSolution0.png

ImportSolution.png

 

Find the CSV To JSON solution in the list of solutions. Select it. Then find the CSV To JSON flow inside the solution package.

Once in the flow, go to the Get file content action & select the CSV you want to work with. Alternatively you could use a different action to get the CSV content as text.

CSVtoDataset1.png

 

After selecting your CSV, go to the Compose CSV data + Set-up action. If you used a different action to get the CSV file content as text, then you will need to input the output of that action in the CSV_Data parameter value (The get file content action you use may return the CSV file as base64, in which case you must use a base64tostring( ) expression on it in the input.

CSVtoDataset2.png

 

Adjust the rest of the parameters for your file. For example if your CSV has extra lines at the header or footer of the sheet/file, then account for those in the HeaderRowsToSkip & FooterRowsToSkip.

CSVtoDataset3.pngCSVtoDataset2-2.png

 

After that, move down to the Select CSV to JSON action. Input the header column names on the left side of the mapping & use the expressions outputs('Compose_CSV_data_+_Set-up')['NewDelimiter'])?[INSERT COLUMN NUMBER HERE STARTING FROM 0] on the right side of the mapping to match up their values. For example in the preceding volunteer contacts CSV example, First Name was the 0 index column so its value expression is outputs('Compose_CSV_data_+_Set-up')['NewDelimiter'])?[0] and Email is the 3rd index column so its value expression outputs('Compose_CSV_data_+_Set-up')['NewDelimiter'])?[3]

CSVtoDataset4.png

 

After that, we need to get the JSON schema for the Parse JSON action. So go & run the flow once. Then in the flow run, go to the outputs of the Select CSV to JSON action & copy the JSON output there.

CSVtoDataset6.png

 

Go back to the flow editor, go to the Parse JSON action, select Use sample payload to generate schema, & paste the JSON output to the sample payload menu. Select Done.

CSVtoDataset7.pngCSVtoDataset8.png

 

Now your CSV columns should be available as dynamic content from the Parse JSON action & you can insert them wherever you need in the rest of your flow.

 

 

 

(If you can export as a semicolon, tab, or other delimited file, then you can probably just use a simpler method like Paul’s here: https://www.tachytelic.net/2021/02/power-automate-parse-csv/?amp)

 

For more information on the delimiter change piece, visit this previous post:

https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Change-CSV-Data-Delimiter-From-a-Text-File/m-p/1442954#M531

 

To make a flow to send any CSV data to a new Excel table with given CSV header names without any column mappings, check this template:

https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/CSV-To-New-Excel-Table/m-p/1826096#M964


*Copying the template into an existing flow may create issues with expressions. You may need to copy the rest of your existing flow into the CSV template flow, then move the template scope where you need it.

 

CSV To JSON Version 3

(More minor fixes & additions.

I adjusted several expressions so it can now handle a few more scenarios with arrays in the CSV data. It should handle any array that doesn't include double quotes and any array that is all strings with double quotes, so ["String1", "String2", "String3"], but it will have issues if it is a mixed array with some double-quoted strings and some other values, for example ["String", 4, 03/05/2022, "String2"] won't work.

I also adjusted how the LineBreak setting is set-up so it now uses the /r/n for the LineBreak. I also provided this link in the flow so anyone can look up the right string for the decodeUriComponent expression(s) if they happen to have different LineBreak characters. This change also made it possible to differentiate between in-data line-breaks and CSV row line-breaks on the files I tested, so it should now replace the in-data line-breaks, like the multiple-choice fields some sites use, with semi-colons. That should make those records much easier to deal with & parse in later actions.
I also looked over a problem with in-data trailing commas. I added a line in the settings where anyone can toggle whether they want it to adjust for trailing OR leading commas in the data, it just can't handle both in one dataset. So if one column in one row has ",String1 String2" and another column in another row has "String 3 String4," then it will have errors.)

 

 

CSV To JSON Auto Columns Version 1

An additional flow version that automatically does the JSON key-value matching. Useful if you may have use-cases with dynamic CSV files that may change each time the flow is run.

 

 

 

If you have any trouble with the standard legacy flow import method, you can also try an alternate Power Apps Solution import method here: Re: CSV to Dataset - Page 8 - Power Platform Community (microsoft.com)

 

Thanks for any feedback,

Please subscribe to my YouTube channel (https://youtube.com/@tylerkolota?si=uEGKko1U8D29CJ86).

And reach out on LinkedIn (https://www.linkedin.com/in/kolota/) if you want to hire me to consult or build more custom Microsoft solutions for you.

Also if you find my free builds/templates helpful, note they are often a by-product of work I do with a USAID contractor.


Solution Zip Download Link: https://drive.google.com/file/d/1jElzcRiC5V-m1m1s2obDl-OtQIeNt0EN/view?usp=sharing

Legacy Power Automate Import: https://drive.google.com/file/d/1fvcDqrW6TfI2Wnamqxc_-pxLM6bG0FwO/view?usp=sharing

Categories:

Comments

  • takolota1 Profile Picture takolota1 4,974 Moderator
    Posted at
    CSV to Dataset

    New screenshot & text guide added to the main post to help some having trouble setting this up.

  • takolota1 Profile Picture takolota1 4,974 Moderator
    Posted at
    CSV to Dataset

    CSV To JSON Auto-Columns V1

    An additional flow version that automatically does the JSON key-value matching. Useful if you may have use-cases with dynamic CSV files that may change each time the flow is run.

    So if you use a CSV like...

    Col1,Col2,Col3

    String1,String2,String3

    String1-2,String2-2,String3-2

     

    Then the final Select action will automatically output the JSON without any manual mapping of the fields to...

    [

    {

    "Col1":"String1",

    "Col2":"String2",

    "Col3":"String3"

    },

    {

    "Col1":"String1-2",

    "Col2":"String2-2",

    "Col3":"String3-2"

    }

    ]

  • takolota1 Profile Picture takolota1 4,974 Moderator
    Posted at
    CSV to Dataset

    @obeddjesus I'm not sure I understand where your current issue is.
    Here is another resource if the 1st did not explain things for you: https://youtu.be/-MFpKx5QdrY?si=35di_VVUxWskGx6M 
    Also if you are already successfully getting a JSON array out of the CSV file, then please create a new community ticket to handle any more questions about the Populate a Word Document connector.
    Thanks,

  • obeddjesus Profile Picture obeddjesus
    Posted at
    CSV to Dataset

    Thanks!!
    I still having issues with the population. I attached the .csv file.

    This is how it looks

    obeddjesus_0-1713202286686.png

     

     

     

  • takolota1 Profile Picture takolota1 4,974 Moderator
    Posted at
    CSV to Dataset

    @obeddjesus 

    You can use the populate a word document connector

    https://youtu.be/ke6cUWzhqXo?si=gn-XquYSMGNZ_HDJ

  • obeddjesus Profile Picture obeddjesus
    Posted at
    CSV to Dataset

    Did you have a way to use it to Populate a Microsoft Word Document Table with the CSV Information something like this.

    obeddjesus_0-1712689892319.png

     

  • takolota1 Profile Picture takolota1 4,974 Moderator
    Posted at
    CSV to Dataset

    @Sanil_Maru It has been a few years since I was at the org with that IT team. I will need to figure out what they did & replicate it soon for a new project I’m working on though.

  • Sanil_Maru Profile Picture Sanil_Maru
    Posted at
    CSV to Dataset

    Hey @takolota ,

     

    I was actually replying to one of your comment in this same post 🙂

    Re: CSV to Dataset - Page 2 - Power Platform Community (microsoft.com)

    Sanil_Maru_0-1709569029162.png

     

  • takolota1 Profile Picture takolota1 4,974 Moderator
    Posted at
    CSV to Dataset

    @Sanil_Maru 

     

    Did you mean to post this somewhere else?

    This is a cloud based CSV parser post.

  • Sanil_Maru Profile Picture Sanil_Maru
    Posted at
    CSV to Dataset

    Hey @takolota !!

     

    I have a similar requirement of setting up a VM which is always on and logged in. Could you please help me with more details on how to set it up in Azure VM?

     

    Thanks!!