remove quotes from csv file data in python
<p>I have a csv that is being imported from url and placed into a database, however it imports with quotes around the names and id like to remove them. The originial format of the csv file is</p>

<pre><code>"Apple Inc.",113.08,113.07
"Alphabet Inc.",777.61,777.30
"Microsoft Corporation",57.730,57.720
</code></pre>

<p>the code I currently have is as follows. </p>

<pre><code>def csv_new(conn, cursor, filename):
    with open(filename, 'rt') as csv_file:
        csv_data = csv.reader(csv_file)
        for row in csv_data:
            if(not row[0][0].isdigit()):
                continue
            split = [int(x) for x in row[0].split('/')]
            row[0] = datetime.datetime(split[2], split[0],
                                       split[1]).date().isoformat()
            print(row);
            cursor.execute('INSERT INTO `trade_data`.`import_data`'
                           '(date, name, price) VALUES(%s, "%s", %s)',
                           row)
    conn.commit()
</code></pre>

<p>final database looks like this </p>

<pre><code> Name   | Price1| Price 2|
'Apple Inc.' 113.08 113.07
'Alphabet Inc.' 777.61 777.30
'Microsoft Corporation' 57.730 57.720
</code></pre>

<p>and I would like it to look like </p>

<pre><code>Name   | Price1| Price 2|
Apple Inc. 113.08 113.07
Alphabet Inc. 777.61 777.30
Microsoft Corporation 57.730 57.720
</code></pre>

<p>I tried using for row in csv.reader(new_data.splitlines(), delimiter=', skipinitialspace=True): but it threw errors</p>

<p>Figured it out, the problem was as tdelaney mentioned was that the quotes were not acually in the string it was python, so my changing value in </p>

<pre><code>cursor.execute('INSERT INTO `trade_data`.`import_data`'
                       '(date, name, price) VALUES(%s, "%s", %s)',
                       row)
</code></pre>

<p>to %s instead of "%s" it fixed the problem and removed the extra quotes. </p>

python mysql csv