0

I currently have a main python script which is working by analyzing a given csv file present in its own local working folder. With the aim of automatizing the process of analyzing more than one csv file, I'm currently trying to build another script which is performing the following tasks:

  1. Download in local working folder a csv file, identified by its own name among the many in an online repository (a OneDrive folder), for which I have the corresponding URL (for the OneDrive folder, not directly the file).
  2. Run the main script and analyze it.
  3. Remove the analyzed csv file from local folder and repeat the process.

I'm having some issues with the identification and download of the csv files. I've seen some approaches using 'request' module but they were more related to downloading directly a file corresponding to a given URL, not looking for it and taking it from an online repository. For this reason I'm not even sure about how to start here. What I'm looking for is something like:

url = 'https://1drv.ms/xxxxxxxxx'
file_name = 'title.csv'
# -> Download(link = url, file = file_name)

Thanks in advance to anyone who'll take some time to read this! :)

Macs
  • 1
  • 1
  • What about this? https://stackoverflow.com/questions/34503412/download-and-save-pdf-file-with-python-requests-module – Ratmir Asanov Nov 03 '21 at 21:18
  • @RatmirAsanov unfortunately no, because this would work if I was pointing directly with the URL to the file I'm interested into. In my case I have a URL from which different csv files can be downloaded, and I need to point to the one corresponding to 'file_name' and the download only that one. – Macs Nov 04 '21 at 18:03
  • Your question is very abstract. Do you have any code snippet? Thanks. – Ratmir Asanov Nov 04 '21 at 19:13
  • @RatmirAsanov I have a private OneDrive folder online, which I can open through the URL I was given providing me the access. Inside this, there are different csv files, each of them named with a given title, for example: 'data1.csv', 'data2.csv', ... I'd like to insert in my python script a given file name I want to download and the URL of the OneDrive folder in which it is found, and then download the corresponding file from there. Hope this can be more helpful :) – Macs Nov 04 '21 at 20:41
  • A possible snippet: /// >> >> file_name = 'data1.csv' >> url = 'https://1drv.ms/xxxxxxxxx' >> * Download routine / command: download in local working folder in my pc 'data1.csv' from https://1drv.ms/xxxxxxxxx * >> /// I'm sorry if this is not useful but I don't really even have a clue about how to even start from here. Just copying the snippet from the answer you've linked or making something similar won't work in this case unfortunately. – Macs Nov 04 '21 at 20:45

0 Answers0