cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
slyuso Advocate II
Advocate II

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
Community Support

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

7 REPLIES 7
Community Support
Community Support

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 Advocate II
Advocate II

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 Advocate I
Advocate I

Re: Sliting multiple lines

Brilliant!

Pavel_Sheludkov Kudo Kingpin
Kudo Kingpin

Re: Sliting multiple lines

Awesome!

Thank you

juresti Responsive Resident
Responsive Resident

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 Advocate I
Advocate I

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.

nutansh07
Regular Visitor

Re: Sliting multiple lines

Hi Jose,

 

This works too but as we are encoding the content, we need to again decode while parsing the results. 

I tested this in a recent flow 😊

 

Thanks,

Nutan

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (8,223)