Removing Empty Lines From .TXT

Hi there,

I need to read the last modified date of various .txt files and keep track of the total number of lines in each. Some of the files come with empty lines in between the data that messed up the total number of lines.

I have been using the Balareva Easy Text Package to delete empty lines and obtain total number of lines in the file, the only problem is that my modified date changes to “Today” or the day that the bot is run.

To obtain the last modified date I am using : directory.GetLastWriteTime(FilePath)

Bot will run on Fridays and Mondays, is there a way to achieve all this without the last modified date changing?

Thank you

@rjackson If a Bot is using a file or even if a Human uses a File, and Saves it , That will be the LastWriteTime of that File. :sweat_smile:, So if you want to use the LastWriteTime of the File later in the Workflow, I guess you’ll need to Save that value to a variable.

1 Like

Hey @rjackson

Hope you’re well and this is not defeating you! The way i would approach this is get the Modified date right at the start, then remove the lines from the text file, and use the previously recorded date instead of the new one.

If you were constantly working on the file though, and need to know last time it was modified, and don’t want your line removal/count execution to be counted as a modified date, i would try this:

Read the last modified date (store as variable), “Write Range” the text to a new text file (call it something like “Temp file for RPA”) and then adjust/remove the empty lines in this new file, not the old one. That way the original file remains un-modified but you still get the text & line counts you need.

Hit me up if you need more info, or if i can assist more.

Cheers
MikeB

1 Like