cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Loic
Level: Powered On

How to select the last line of a text content ?

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

Flow-lastline.png

but it fails because file content is type of Object instead of table/string ...2018-01-04 12 06 26.png

 

 

 

6 REPLIES 6
Community Support Team
Community Support Team

Re: How to select the last line of a text content ?

Hi Loic,

 

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.

3.PNG

 

Please take this for a reference. Please feel free reply if you need more help.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Loic
Level: Powered On

Re: How to select the last line of a text content ?

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 ?2018-01-22 11 09 58.png

 

2018-01-22 11 11 11.png

 

Community Support Team
Community Support Team

Re: How to select the last line of a text content ?

Hi @Loic,

 

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.

For example:

split('a;b;c',';')

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.

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Loic
Level: Powered On

Re: How to select the last line of a text content ?

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...

Regards, 

Loïc

Community Support Team
Community Support Team

Re: How to select the last line of a text content ?

Hi @Loic,

 

To Split the New line, you may take a try with the code below:

split('a;b;c','
')

 

See if this would make it work.

 

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
slyuso
Level: Powered On

Re: How to select the last line of a text content ?

This does not work

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 40 members 4,993 guests
Please welcome our newest community members: