I will get finance info from the alpha vantage API and I will write the answer directly in my database.
It works great but the first row of the CSV answer is the header.
How can I skip the first row?
Thank's a lot.
#db-connection#
import mysql.connector
mydb = mysql.connector.connect(host="localhost",port="+++",user="+++",passwd="+++",database="++++")
mycursor = mydb.cursor()
#data#
from alpha_vantage.timeseries import TimeSeries
import csv
ts = TimeSeries(key='+++++', output_format='csv')
data, meta_data = ts.get_intraday(symbol='MSFT',interval='1min', outputsize='compact')
print(data)
#write data in db#
for row in data:
mycursor.execute('INSERT INTO import (date ,open, high, low, close, volume) Values (%s,%s,%s,%s,%s,%s)',row)
mydb.commit()
print("1 record inserted, ID:", mycursor.lastrowid)
mycursor.close()
mydb.close()
print("Connection Closed")
The first row in the database is the header from the API / CSV answer.