Here is an example of how to automatically download files from SharePoint Online by using PowerShell. By knowing how to run PowerShell script from the Windows command line (CMD) you can also build a workaround to download files during R or Python script execution.