Hi there I cannot figure out how to extract the last line of a text content, anyone knows how to solve this please?
I've tried to use the last() formula
but it fails because file content is type of Object instead of table/string ...
The error message says that the function last expects an array, however, the return value of action “Get file content” is binary.
Please consider using the actions of Variables to convert the return value of Get file content to an array.
In the action Set variable, use the function createarray to create an array from the parameters.
Please take this for a reference. Please feel free reply if you need more help.
Hi Mabel Mao thank you for your reply. I tried yout suggestion but last function still send me the whole array instead of the last line. Did I missed something ?
You didn't miss anything.
What Mabel means is that first you should build an array for your Text content.
If there is no array, then the whole Text content would be considered as a single string.
To create an array for each line, we could workaround this with the Split() function.
This would return the following Array:
["a", "b", "c"]
Please consider add a separator at the end of each line, make sure this character is different from characters within the Text content.
Then you should be able to use the Last function to get the Last line.
HI @v-micsh-msft and @v-yamao-msft, I thought this was the goal of the CreateArray(outputs('compose')) formula .... What if I can t add a separator in the input file ? Can I split file on CR/LF séparator ? maybe \n\r ??
Seems to me there should be a built-in formula or activity that transform file content to array, especially if Flow is designed for non developpers people...
To Split the New line, you may take a try with the code below:
See if this would make it work.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!