cancel
Showing results for 
Search instead for 
Did you mean: 

Text (CSV) file - get rows

An action to get rows from a text file (CSV) would be handy.

Status: New
Comments
DamoBird365
Super User

I appreciate things have moved on a lot since 2018 but here is my relatively simple method (and appreciate it handles basic CSV's) but it's a good starting concept for some.

 

DamoBird365_0-1628329592454.png

The select turns the array of lines split by a return into key/value pairs:

DamoBird365_1-1628329898124.png

 

If you combine this method with my create a new excel file video it is possible to quickly convert CSV to an Excel Table too. I am also an excel office script fan.

 

In a bit more detail, I have covered how to accept CSVs from various inputs, SharePoint, OneDrive and Email, as well as dealing with the different encodings.  I would appreciate any feedback on this method too and I hope it helps some that are looking to understand and develop new ideas.

asmusz
Advocate II

I appreciate that everyone is being helpful and providing their ways to "work around" this limitation, but IMO....... it's utterly ridiculous that MS did not include a native action to easily handle CSV data.  Before we had JSON, and/or XML, it was the main method for data exchange, AND there are still scads of systems where csv is the only easily available export format.

 

In PowerShell this takes 2 lines of code.  The process in Power-Automate should be just as easy/simple.

DamoBird365
Super User

Hi all,I believe Microsoft have come up with the solution now, in the form of excel office scripts. https://docs.microsoft.com/en-us/office/dev/scripts/resources/samples/convert-csv This enables you to easily convert a windows encoded csv to excel file. I have a video demo, https://youtu.be/9J6ThPWGaG0, showing you how you can handle different file encodings for the return line and insert a table into the new excel file via the script, so that you can then select rows based on the existing excel actions. Hope this is of use to everyone. 

asmusz
Advocate II

Again @DamoBird365 , Appreciate you being helpful. ( Yes I REALLY DO 🙂 )  I have created a nifty Flow that can be passed a CSV string and return it as JSON, and your solution may function, but again I feel both my solution and yours are way more complex for something that takes just a couple lines of code in most programming languages than they should need to be.  CSV is not a complex structure.  It's a table, or an associative 2-dimensional array.  There should just be an action "Parse-CSV" that will return ANY CSV string as JSON.