D-Mielewczyk / euro-temperature-trend-stats

MIT License
0 stars 0 forks source link

Create a Python Script to Fetch Data from ECA&D #1

Closed D-Mielewczyk closed 3 weeks ago

D-Mielewczyk commented 3 weeks ago

Develop a Python script that automates the process of fetching climate data from the European Climate Assessment & Dataset (ECA&D) website. The primary goal is to fetch the data directly using Python code. If this proves challenging, an alternative approach of manually downloading and then uploading it to an S3 bucket can be considered as a backup solution.

Requirements:

  1. The script should:
    • Fetch climate data directly from ECA&D.
    • Save the fetched data locally in a specified format (e.g., CSV).
  2. If fetching the data directly is difficult:
    • Provide clear instructions on how to manually download the data from the ECA&D website.
    • Include a Python script that uploads the manually downloaded data to an S3 bucket (backup solution).

Details:

Acceptance Criteria:

Additional Notes:

Example:

Here is an example of a possible implementation approach for fetching data directly:

import requests

def fetch_data(url, local_filename):
    try:
        response = requests.get(url)
        response.raise_for_status()  # Check for request errors
        with open(local_filename, 'wb') as file:
            file.write(response.content)
        print(f"Data fetched and saved to {local_filename}")
    except requests.exceptions.RequestException as e:
        print(f"Error fetching data: {e}")

if __name__ == "__main__":
    url = 'https://www.ecad.eu/download/data.csv'  # Example URL, replace with the actual URL
    local_filename = 'data.csv'

    fetch_data(url, local_filename)

Feel free to refine and improve this example script as needed.