I'm new to pyhton and just tried to write data from external file. I have no idea where i'm going wrong. can anyone please help me with this. Thanks in advance.
from urllib import request
url = r'https://query1.finance.yahoo.com/v7/finance/download/AMD?period1=1497317134&period2=1499909134&interval=1d&events=history&crumb=HwDtuBHqtg0'
def download_csv(csv_url):
csv = request.urlopen(csv_url)
csv_data = csv.read
csv_str = str(csv_data)
file = csv_str.split('\\n')
dest_url = r'appl.csv'
wr = open(dest_url, 'w')
for data in file:
wr.write(data + '\n')
wr.close()
download_csv(url)