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

Sliting multiple lines


Intialize a variable named "A" of type string and enter a couple of lines of text. Then use Compose to split it. Run.


Flow.PNG














Then, check execution.

Variable.PNG
This was expected.
But the next was not. See result below:
Result.PNG
I also tried use:
split(variables('A'),'
')
This was accepted as expression but result was the same.

split(variables('A'),'\r\n')
produced the same result.

What is wrong here ?

P.S. My ultimate goal is to parse a multi-line CSV text file from Sharepoint document library. Yes, I'm aware of Excel connector. 






 



 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Sliting multiple lines

Hi @slyuso,

 

Thanks for the feedback.

I think the issue here should be the

split(variables('A'),'
')

As the 

'
'

Will not be considered as a valid character in flow expression, per my testing.

 

To workaround this, please take a try to create an example first, then get the New Line character, after that, use the NewLine Compose output as the Split string:

Follow the steps below:

1. Create a string variable as below, make sure to enter two spaces after Line1, then press enter:

Line1  
Line2

46.PNG

 

2. Add Compose, under the Input, enter the expression below:

take(first(skip(split(Variables('A'),'  '),1)),1)

47.PNG

 

3. After that, we could use the Outputs of the Compose to split the string with the Line break character:

split(variables('A'),outputs('Compose'))

48.PNG

 

4. The running results:

49.PNG

 

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.

View solution in original post

6 REPLIES 6
Community Support Team
Community Support Team

Re: Sliting multiple lines

Hi @slyuso,

 

Thanks for the feedback.

I think the issue here should be the

split(variables('A'),'
')

As the 

'
'

Will not be considered as a valid character in flow expression, per my testing.

 

To workaround this, please take a try to create an example first, then get the New Line character, after that, use the NewLine Compose output as the Split string:

Follow the steps below:

1. Create a string variable as below, make sure to enter two spaces after Line1, then press enter:

Line1  
Line2

46.PNG

 

2. Add Compose, under the Input, enter the expression below:

take(first(skip(split(Variables('A'),'  '),1)),1)

47.PNG

 

3. After that, we could use the Outputs of the Compose to split the string with the Line break character:

split(variables('A'),outputs('Compose'))

48.PNG

 

4. The running results:

49.PNG

 

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.

View solution in original post

slyuso
Level: Powered On

Re: Sliting multiple lines

Thank you, Michael
Your post inpired me for even a simpler solution.

CRLF.PNG
To define variable CRLF, I pressed ENTER key. This is not obvious from the picture 
And it worked  as in your example.
Thank you for helping.

Gaolai
Level: Powered On

Re: Sliting multiple lines

Brilliant!

Highlighted

Re: Sliting multiple lines

Awesome!

Thank you

juresti
Level 8

Re: Sliting multiple lines

This will be very useful in working with csv files.

 

I'm still working on and searching for a solution to do this same thing with TAB delimited.

 

Update: I just realized you can press tab in notepad then copy it into flow and that lets you split tab delimited files.

JoseZald101
Level: Powered On

Re: Sliting multiple lines

This could also work, but I have not tried it. This is the original post

https://powerusers.microsoft.com/t5/Building-Flows/Replace-Newline-in-Flow-Expression/td-p/57333

Converting it to an array should something like this:

 

split(uriComponent(body('Html_to_text')), '%0A')

 If someone could confirm, please let reply.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,936)