I have a csv file that contains client number, address and premium. It's exported from another system, so the fields have quotes. While importing in R, I face an issue due to unwanted quotes and commas inside string. See example (Client 1 and 2 are correct, client 3 has the issue)
Client number Address Premium
"1" "Building5, Street 30,NY" 1000
"2" "Building7, Street 10,NY" 1000
"3" "Building 7\", Street 10,NY" 1000
Because of this , R reads it as a new 4th column which I don't want. How do I get rid of it programmatically. I am ok with an R or Python based solution that cleans up the csv . If correcting the problem is difficult, even deleting client 3 is an acceptable solution
Tried doing this in python but doesn't help
import csv
def remove_special_prob(s):
return ''.join(c for c in s if c not in ('\"'))
with open("Client.csv","rb") as infile, open("Client_new.csv","wb") as outfile:
reader = csv.reader(infile)
writer = csv.writer(outfile, quoting=csv.QUOTE_ALL)
for line in reader:
writer.writerow([remove_special_prob(elem) for elem in line])