I had the problem parsing a csv file with a Power Automate flow, that in the last column I get a „\r“.
I mean the special character „\r“, not a backslash as one character and an „r“ as an character. That would be displayed as „\\r“.
To remove the character, I tried many things, and the following is my favourite. I use
to replace the special character.
My expression is:
if(empty(replace(items('for_each')?['OrderReference'],decodeUriComponent('%0D'),'')), null, replace(items('for_each')?['OrderReference'],decodeUriComponent('%0D'),''))
With this statement I check, it the items value „OrderReference“ in my for each loop is empty with removing the special character „\r“.
If you want to replace „\n“ use:
PS: The file is stored in a SharePoint doc library. When I read the file content, in the next action I put the rows of the csv file into an array variable with:
split(replace(replace(base64ToString(outputs('Dateiinhalt_abrufen')?['body/$content']),'"',''),outputs('Verfassen_-_Enter'), '#CRLF#'), '#CRLF#')
First, convert the base64 string to a readable string, than replace line end with the string „#CRLF“ and then split the string by using „#CRLF#“ as a separator. Store the result in a array variable.
PPS: To separate the rows I simply use the output of a compose action with a pressed „Enter“ in it.