I have a test.txt. The content of test.txt is shown below: | 55 | 77 | 02 | 30 | A0 | 10 | D0 | 11 | 78 | 70 | 99 | 19 | 00 | A0 | 0B | AA | | 55 | 77 | 02 | 30 | A0 | 10 | D0 | 11 | 78 | 70 | 99 | 19 | 00 | A0 | 0B | AA | | 55 | 77 | 02 | 30 | A0 | 10 | D0 | 11 | 78 | 70 | 99 | 19 | 00 | A0 | 0B | AA | I want to convert string to hex and save it to test.csv. The expected results are shown below: 30027755 11D010A0 19997078 AA0BA000 30027755 11D010A0 19997078 AA0BA000 30027755 11D010A0 19997078 AA0BA000 I have tried the following code, but the output is not what I want. import re import numpy as np import matplotlib.pyplot as plt def split(delimiters, string, maxsplit=0): regexPattern = '|'.join(map(re.escape, delimiters)) return re.split(regexPattern, string, maxsplit) f = open('test\\test.txt') n = 0 while n < len(Lines): delimiters = " " words = split(delimiters, Lines[n]) print(n,words,len(words)) delimiters = " " words2 = split(delimiters, Lines[n]) print(words2,"LEN=",len(words2)) delimiters = "|", "\n" words2 = split(delimiters, Lines[n]) print(words2[4]+words2[3]+words2[2]+words2[1]) n = n + 1 It is not possible to combine these values. 30 02 77 55 Continue reading...