The error I am recieving is this:
_csv.Error: iterator should return strings, not bytes (did you open the file in text mode?)
Where in my code would I open the file in text mode?
import csv
import urllib.request
import pymysql.cursors
connection = pymysql.connect(host='localhost',
user='',
password='',
db='mydb',
charset='utf8',
cursorclass=pymysql.cursors.DictCursor)
try:
url = 'https://api.iextrading.com/1.0/stock/market/collection/sector?
collectionName=Health%20Care&format=csv'
response = urllib.request.urlopen(url)
csv_data = csv.reader(response)
for row in csv_data:
cursor.execute('INSERT INTO Financials (names, \
classes, mark )' \
'VALUES("%s", "%s", "%s")',
row)
finally:
connection.close()