Skip to content

Obtain real-time weather data for any location globally with OpenWeather API.

License

Notifications You must be signed in to change notification settings

y0geshx/weather-data-fetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather Data Fetcher

This project fetches weather data for a list of cities using the OpenWeatherMap API. It retrieves both current city data and forecast data.

GitHub License

Features

  • Fetches current weather data for a list of cities.
  • Fetches forecast data for each city.
  • Displays the collected data in a readable format.
  • Exports data in CSV, XML, HTML, and JSON formats.

Requirements

  • Python 3.x
  • requests library
  • pandas library
  • tqdm library

Installation

  1. Clone the repository:

    git clone https://github.com/y0geshx/weather-data-fetcher.git
    cd weather-data-fetcher
  2. To activate a Python virtual environment in your project, follow these steps:

  3. Create a virtual environment (if you haven't already):

    python -m venv venv
  4. Activate the virtual environment:

    source venv/bin/activate

    After activating the virtual environment, you can install the required dependencies and run your scripts within this isolated environment.

  5. Install the required libraries:

    pip install requests pandas tqdm
  6. Or use:

    pip install -r requirements.txt

Usage

  1. Set your OpenWeatherMap API key in the weather.py script:

    API_KEY = 'your_api_key_here'
  2. Prepare a CSV file with a list of cities. The CSV should have a column named City.

  3. Run the script:

    python weather.py
  4. The script will fetch and display the weather data for the listed cities.

  5. Export the data in the desired format:

    # Example for exporting data
    data.to_csv('weather_data.csv')
    data.to_json('weather_data.json')
    data.to_html('weather_data.html')
    data.to_xml('weather_data.xml')

Example

Here is an example of how to use the script:

  1. Create a CSV file named in_cities.csv with the following content:

    City
    London
    Paris
    New York
    
  2. Run the script:

    python weather.py
  3. The script will fetch and display the weather data for the listed cities.

  4. Export the data in the desired format:

    data.to_csv('weather_data.csv')
    data.to_json('weather_data.json')
    data.to_html('weather_data.html')
    data.to_xml('weather_data.xml')

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Obtain real-time weather data for any location globally with OpenWeather API.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages