I want to download the file in the following url using python. I tried with the following code but it seems like not working. I think the error is in the file format. I would be glad if you can suggest the modifications to the code or a new code that I can use for this purpose
Link to the website
https://www.gov.uk/government/statistics/transport-use-during-the-coronavirus-covid-19-pandemic
URL required to be downloaded
My Code
from urllib import request
response = request.urlopen("https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/959864/COVID-19-transport-use-statistics.ods")
csv = response.read()
csvstr = str(csv).strip("b'")
lines = csvstr.split("\\n")
f = open("historical.csv", "w")
for line in lines:
f.write(line + "\n")
f.close()
Here basically I only want to download the file. I have heard that Beautifulsoup can be used for that but I don't have much experience on this. Any code that would serve my purpose is highly appreciated
Thanks
