import re
regex = r"("([^"]+)",?|([^,]+),?|,)"
test_str = ""ABG090D",2019-03-03 00:00:00.0000000,"A","some Data C" AB01","Some Data","LOS","NEW",2019-04-11 00:00:00.0000000,"GHYTR","7860973478","0989","A",2019-03-03 00:00:00.0000000,"Y","N","N","N",1,"N","D016619",,"$,$#,&","Y", "69901",,,,"FGF",89.00,"W",,"N","R","F",5.00,6.00,6.00,9.00,2.00,0,0,"9090",,"N",,,"1","N",,,"F",,2019-03-03 00:00:00.0000000,,,,,"N","A","N","N","N","N","N",,,,,,,"H",,,,,,,,,,"N","A","0","0","0",,0,0,0,0,0,0,0,"N","00","USA", "C","I",0,,,,"FGF",0,,,"N","UOIU","5",,0,,0,0,,,"878","N",2019-04-11 09:44:00.0000000,"8980909","H",,,,"N","2","T","SomeData", 2020-03-12 09:24:52.0000000"
matches = re.finditer(regex, test_str, re.MULTILINE)
values = []
for matchNum, match in enumerate(matches, start=1):
if match.group(3) != None:
values.append(match.group(3))
elif match.group(2) != None:
values.append(match.group(2))
else:
values.append(None)
print(values)