Instead of using a regular expression, an approach is used that uses Python string functions to find and exclude only quotes between left and right string quotes.
.find() .rfind() ". ", . , ,, (, '\n' ).
def escape_internal_quotes(item):
left = item.find('"') + 1
right = item.rfind('"')
if left < right:
item = item[:left] + item[left:right].replace('"', '\\"') + item[right:]
return item
line = '"0","0.23432","234.232342","data here dsfsd hfsdf","3/1/2016",,"etc","E 60"","AD"8"\n'
escaped = [escape_internal_quotes(item) for item in line.split(',')]
print(repr(','.join(escaped)))
:
'"0","0.23432","234.232342","data here dsfsd hfsdf","3/1/2016",,"etc","E 60\\"","AD\\"8"\n'