Removing lines and carriage return in text files

Removing lines and carriage return in text files

  
Hi ppl!
I'm struggling with something so ridiculous!

I have a text file, if I open it in Notepad, I see one long string and some squares (line return)
When I open it in Word, I see the text splited in lines.
OK! The file is like this.

But...

In OutSystems I need to ignore these lines/squares/whatever.

So I'm doing all kind of replaces and nothing work!! Somebody could give me a hand?

- I read the file using File_ReadText component.
- Then the result (FileContent = File_ReadText.Text) I do:

Replace(Replace(Replace(FileContent,NewLine(),""),"\n",""),"\r\n","")

And when I debug, the preview window still shows me the lines and doesn't replace anything!
And doesn't replace indeed, because I read data and it is ""

Thank you!
Carolina
Hi Carolina,

It is possible to send us some sample file?

Regards,
Rafael Pereira
Hi Carolina,

While sending us the sample file, and an example, as Rafael is suggesting, there is also an alternative you might want to explore.

The way you're doing it is not quite correct: Replace(Replace(Replace(FileContent,NewLine(),""),"\n",""),"\r\n","")

Since it evaluates from the inner-most expression to the outer-most, what may happen is that you'll be left with some \r characters there. The best way to do this would be:

Replace(Replace(Replace(FileContent,"\r\n",""),"\n",""),NewLine(),"")

and I'm assuming you're using an assign node to store this result (or that you're using this result in an input parameter for something, or directly in an expression).

If this doesn't work, I'd suggest trying to do it in an extension, seeing if it changes the behavior.

Regards,

Paulo Tavares
Hi!!
Thank you for your reply, I did change but still doesn't work.
:(
Find the file attached.
I'll continue trying.
Cheers
Carolina
Hi!!
I did it in an extension and it works now.
:D
Thank you!
Hi Carolina,

Good to hear! :) Keep up the good work.

Regards,

Paulo Tavares
Hi!

This will do the trick :)

Replace(Replace(FileContent,Chr(10),""),Chr(13),"")