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
"Apple Inc.",113.08,113.07
"Alphabet Inc.",777.61,777.30
"Microsoft Corporation",57.730,57.720
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()
Name | Price1| Price 2|
'Apple Inc.' 113.08 113.07
'Alphabet Inc.' 777.61 777.30
'Microsoft Corporation' 57.730 57.720
Name | Price1| Price 2|
Apple Inc. 113.08 113.07
Alphabet Inc. 777.61 777.30
Microsoft Corporation 57.730 57.720
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
cursor.execute('INSERT INTO `trade_data`.`import_data`' '(date, name, price) VALUES(%s, "%s", %s)', row)
to %s instead of "%s" it fixed the problem and removed the extra quotes.