First time here? Checkout the FAQ!
x
+2 votes
324 views
asked in Python by (660 points)  

I am not sure why my below code is not working any thoughts ?

https://repl.it/@Neo_sauga/UnselfishFatBrains

  

1 Answer

+1 vote
answered by (116k points)  

Use the following code, and do not forget the space in URLs should be converted to %20. You can run the code here.

import os
import urllib.request

def fetch_credit_card_data(url, directory, file_name):
    if not os.path.isdir(directory):
        os.makedirs(directory)
    urllib.request.urlretrieve(url, directory+'/'+file_name)


url = "https://archive.ics.uci.edu/ml/machine-learning-databases/00350/default%20of%20credit%20card%20clients.xls"
directory = 'directory'
file_name = 'credit_card.xls'

fetch_credit_card_data(url, directory, file_name)

 

...