Вам не нужно escapechar
, если в кавычках нет QUOTE_NONE
и doublequote
- True (по умолчанию).
>>> import csv, sys
>>> w = csv.writer(sys.stdout)
>>> w.writerow([1,'"ab"','c,','d e', 'f', 'g\\'])
1,"""ab""","c,",d e,f,g\
>>> w = csv.writer(sys.stdout, quoting=csv.QUOTE_NONE,escapechar='\\')
>>> w.writerow([1,'"ab"','c,','d e', 'f', 'g\\'])
1,\"ab\",c\,,d e,f,g\\
>>> w = csv.writer(sys.stdout, doublequote=False,escapechar='\\')
>>> w.writerow([1,'"ab"','c,','d e', 'f', 'g\\'])
1,\"ab\","c,",d e,f,"g\"