trying to replace comma between 2 words Durango and PC in the second line by & and then remove the quotes " as well. Same for third line with Orbis and PC I would like to retain the rest of the lines using Python:
2,SIN-Rendering,Core Tech - Rendering,PC,147,Reopened
2,Kenny Chong,Core Tech - Rendering,"Durango, PC",55,Reopened
3,SIN-Audio,AAA - Audio,"Orbis, PC",13,Open
...
...
...
Like these, there can be 100 lines in my sample. So the expected output is:
2,SIN-Rendering,Core Tech - Rendering,PC,147,Reopened
2,Kenny Chong,Core Tech - Rendering, Durango & PC,55,Reopened
3,SIN-Audio,AAA - Audio, Orbis & PC,13,Open
...
...
...
So far, I could think of reading line by line and then if the line contains quote replace it with no character but then replacement of symbol inside is something I am stuck with.
How to achieve this, any suggestion? Learning Python.
解决方案
Something like below:
st = "2,Kenny Chong,Core Tech - Rendering,\"Durango, PC\",55,Reopened"
res = re.sub(r'\"(.*),\ (.*)\"',lambda x : (" & ").join(re.findall(r'\"(.*),\ (.*)\"', st)[0]),st)