I have a .csv files that might have brackets mixed in:
line = "fdf,dfdf,(1,2,3,4,5),(ss,dd),"
Now I want to replace all the () with "", so that it looks like this:
line = 'fdf,dfdf,"1,2,3,4,5","ss,dd",'
My code is:
line=re.sub(',(', ',"', line)
line=re.sub('),', '",', line)
However I got this error:
...
File "/usr/local/Python-2.7/lib/python2.7/re.py", line 151, in sub
return _compile(pattern, flags).sub(repl, string, count)
File "/usr/local/Python-2.7/lib/python2.7/re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: unbalanced parenthesis
What is wrong here?!!