I’m reading text that contains non-printable characters such as backspaces from a file example.log
.
If I’m reading the content of the file in a terminal running cat example.log
, I obtain a well formatted string:
Loading file /path_to/some_db/hold_fix_crash.db
But there are some backspaces and other non printable characters in the file. When I run the command cat example.log -v
(the -v
option shows non printable characters), I obtain
Loading file /path_to/some_db/hold_f ^Hix_crash.db
I need to read the file in a python script, process some lines and write them back in a file. How can I process the text in these files to obtain the printed “cat” version of the string, when the backspace has been processed and is not in the string anymore ?
If possible, I’m looking for a built in solution that would process all the problematic non printable characters.