First, I didn't find anything to resolve "comma inside qoutes, issue"
systematically and properly. The pandas=1.5.3 is unable to parse it
correctly. Tried to specify parameters like qoutechar, quoting,
escapechar, lineterminator, ...
Finally, found two workaround solutions taking advantage I know the comma could be in the last column only.
Assume following content of csv
userid, username, body
1, Joe, string1
2, Jim, "string21, string22"
If you don't mind the part after 3rd comma is lost then specify number of columns
pd.read_csv(r'c:\TEMP\to_parse.csv',usecols=range(3))
which yields
userid username body
0 1 Joe string1
1 2 Jim "string21
Second workaround is more complicated but it yields complete string with comma. The principle is to replace first 2 commas by semicolon (you must know the number of columns)
with open(path, 'r') as f:
fo = io.StringIO()
data = f.readlines()
fo.writelines(u"" + line.replace(';', ':').replace(',', ';', 2) for line in data)
fo.seek(0)
df = pd.read_csv(fo, on_bad_lines='warn', sep=';')
Perhaps it could be accomplished by regex as well.