Identify and replace empty lines in txt file

Hi there, I have an invoice file coming in a txt form. When I use the Read Text File activity, the output string removes any empty lines. The empty lines between lines are essential in order to distinguish elements of the invoice as read from the system.

I want to find a way to read the text file and replace those empty lines with 0 in order to later perform string manipulation activities.

Can someone help?

it should not and we also use this along with the empty lines.
Please share some details (screenshots) from your modelled flow. Thanks

Are you seeing the values from a Log Message activity? I’ve seen that activity trim output before, even though the value in the variable has the extra spaces, lines, etc. If that’s correct, I suggest testing by writing the variable back out to a different text file, and you should see that the extra lines are indeed still there.

Why would you replace the empty lines with 0? That would mean you identify the empty line by the existence of two carriage returns in a row, then replace them with 0. But you could just do your “later string manipulation” based on the two carriage returns. Replacing with 0 sounds like an unnecessary extra step.

Oh and another option to handle the empty lines is to split the entire thing into an array, based on VbCrLf. Then your empty lines will become empty items in the array. This makes it easy to identify them, change their values, and then Join everything back together (or For Each through the array depending on your needs).

Hello @moon_amlet ,

Is this Text form a .txt file? If yes, and if you open it with notepad are you able to see the required empty lines? And is it missing only while using the Uipath Read Text Activity?

Plz confirm the above. Usually Read Text Activity will read a file as it is retaining the spaces and new lines.