Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def remove_trailing_empty_line(file_path):
- """
- Removes any trailing empty line at the end of the file.
- :param file_path: Path to the file to be processed
- """
- # Read the file and remove trailing newline characters
- with open(file_path, "r") as file_input:
- file_data = file_input.read().rstrip('\n')
- # Write the processed data back to the file
- with open(file_path, "w") as file_output:
- file_output.write(file_data)
- # Example usage of the function
- remove_trailing_empty_line(r"C:\Scripts\Archive.ph Link Saver\Resources\Data\Newly Modified URLs.txt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement