Hello, i currently have a list with one element inside each. Is there a way python can combine the first two lists into one? I tried my code down below. The last for loop Is my attempt. If you see the actual output, it only duplicates it but doesnt get the second element. I need the first and second element to be listed together.
input:
['d0123456789']
['49416494949']
['46497616494']
['497522339533388']
current output:
['d0123456789', 'd0123456789']
['49416494949','49416494949']
['46497616494', '46497616494']
['497522339533388','497522339533388']
expected output:
micr_ocr_dat_l =[]
['d0123456789','49416494949']
['46497616494', '497522339533388']
code:
for fp in dat_filepath:
with open(fp, 'r', encoding="ISO-8859-1") as in_file:
data = in_file.readlines()
for row in data:
micr_ocr_line = re.findall(r'd[^d]*d[^d]*c[0-9]+|d[^d]*d[^d]*c\s+[0-9]+', row)
for r in micr_ocr_line:
rmve_spcl_char = re.sub (r'([^a-zA-Z-0-9]+?)', '', r)
rmve_spcl_char = re.sub(r'(c\d{4,}).*', r'\1', rmve_spcl_char)
a = [l for l in rmve_spcl_char.split('\n')]
for previous, current in zip_longest(a, a[::1]):
print(previous, current)
micr_ocr_dat = [previous, current]
print(micr_ocr_dat)
micr_ocr_dat_l.append(micr_ocr_dat)