cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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

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

Highlighted
Advocate I
Advocate I

Re: Sliting multiple lines

Brilliant!

Highlighted
Anonymous
Not applicable

Re: Sliting multiple lines

Awesome!

Thank you

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

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

Highlighted
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

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,233)