We could filter the data from the serial line using this regular expresssion:
'\x1b\[[0-9;]*m'
An example:
$ cat /tmp/remove-ansi-codes.py import re import sys
input_file = sys.argv[1]
with open(input_file, 'r') as data: for line in data.readlines(): filtered = re.sub('\x1b\[[0-9;]*m', '', line) print(filtered.strip())
We could filter the data from the serial line using this regular expresssion:
'\x1b\[[0-9;]*m'
An example:
$ cat /tmp/remove- ansi-codes. py
import re
import sys
input_file = sys.argv[1]
with open(input_file, 'r') as data: '\x1b\[ [0-9;]* m', '', line)
print( filtered. strip() )
for line in data.readlines():
filtered = re.sub(