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.
5 REPLIES 5
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.
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!

Re: Sliting multiple lines

Awesome!

Thank you

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

>