I have a huge CSV file with sample data that looks like so:
"Name";"Current balance";"Account";"Transfers";"Description";"Payee";"Category";"Date";"Memo";"Amount";"Currency";"Check #";"Tags"
"Capital One Quicksilver";"-119.99";"USD";"";"";"";"";";"";"";";"";""
"";"";"Capital One Quicksilver";"";"DMV";""Carfax";"";"08/19/2004";"";"-24.99";"USD";"";""
"";"";"Capital One Quicksilver";"";"DMV";""Carfax";"";"08/19/2004";"";"-24.99";"USD";"";""
"";"";"Capital One Quicksilver";"";"Gas";""USA Petroleum";"";"09/13/2004";"";"-20.43";"USD";"";""
The original CVS file had some unnecessary characters that I removed to obtain the data as shown above using the following code:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import scipy as sp
text = open("report.csv", "r")
text = ''.join([i for i in text]) \
.replace('old', 'new')
x = open("report_mod.csv","w")
x.writelines(text)
x.close()
Where I'm stuck now is, how do I replace the double quotes ("") with single quotes (") for all the entries of the field column Payee?
In the above example, the 3 entries for the Payee is ""Carfax", ""Carfax", and ""USA Petroleum". I would like to replace the double quotes at the beginning with single quotes, i.e. "Carfax", "Carfax", and "USA Petroleum"
The new CSV file should look like so:
"Name";"Current balance";"Account";"Transfers";"Description";"Payee";"Category";"Date";"Memo";"Amount";"Currency";"Check #";"Tags"
"Capital One Quicksilver";"-119.99";"USD";"";"";"";"";";"";"";";"";""
"";"";"Capital One Quicksilver";"";"DMV";"Carfax";"";"08/19/2004";"";"-24.99";"USD";"";""
"";"";"Capital One Quicksilver";"";"DMV";"Carfax";"";"08/19/2004";"";"-24.99";"USD";"";""
"";"";"Capital One Quicksilver";"";"Gas";"USA Petroleum";"";"09/13/2004";"";"-20.43";"USD";"";""
Sample data file: report.csv