- import requests
- # Function to download the file
- def download_file(url, filename):
- with open(filename, 'wb') as f:
- response = requests.get(url)
- f.write(response.content)
- # URL to the endpoint that provides details of the file
- details_url = "https://toolkit.tesco.com/partner/reports/api/v1/generated-reports-v2?pageNumber=0&pageSize=18"
- # Making a request to get the report details
- response = requests.get(details_url)
- # Assuming the response contains the necessary details, including the URLs of the files
- # Extracting the URLs of the files from the response JSON
- report_details = response.json()
- # Find the report with the latest createdOn timestamp
- latest_report = max(report_details['reports'], key=lambda x: x['createdOn'])
- # Extract the URL of the CSV file with the latest createdOn timestamp
- csv_url = latest_report['reportName']
- # Download the CSV file
- download_file(csv_url, "/dbfs/path/to/save/latest_sales_and_stock_mapping.csv")
- print("Latest file saved to DBFS successfully!")
[text] H
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: