<jupyter_start><jupyter_text>Download a data setThis notebook downloads a data set file from a public location. If the data set file is a compressed archive it will be decompressed. Upon completion the raw data set files  are located in the `data\` directory.This notebook requires the following environment variables: -  `DATASET_URL` Public data set URL, e.g. `https://dax-cdn.cdn.appdomain.cloud/dax-fashion-mnist/1.0.2/fashion-mnist.tar.gz`<jupyter_code>import glob
import os
from pathlib import Path
import requests
import tarfile
from urllib.parse import urlparse<jupyter_output><empty_output><jupyter_text>Verify that the `DATASET_URL` environment variable is set. If it is not set, a RuntimeError is raised.<jupyter_code>data_file = os.getenv('DATASET_URL',
                      'https://dax-cdn.cdn.appdomain.cloud/'
                      'dax-noaa-weather-data-jfk-airport/1.1.4/'
                      'noaa-weather-data-jfk-airport.tar.gz')<jupyter_output><empty_output><jupyter_text>Download the data set from the location specified in `dataset_url`, extract it (if it is compressed) and store it in the directory identified by `data_dir_name`.<jupyter_code>data_dir_name = 'data'

print('Downloading data file {} ...'.format(data_file))
r = requests.get(data_file)
if r.status_code != 200:
    raise RuntimeError('Could not fetch {}: HTTP status code {}'
                       .format(data_file, r.status_code))
else:
    # extract data set file name from URL
    data_file_name = Path((urlparse(data_file).path)).name
    # create the directory where the downloaded file will be stored
    data_dir = Path(data_dir_name)
    data_dir.mkdir(parents=True, exist_ok=True)
    downloaded_data_file = data_dir / data_file_name

    print('Saving downloaded file "{}" as ...'.format(data_file_name))
    with open(downloaded_data_file, 'wb') as downloaded_file:
        downloaded_file.write(r.content)

    if r.headers['content-type'] == 'application/x-tar':
        print('Extracting downloaded file in directory "{}" ...'
              .format(data_dir))
        with tarfile.open(downloaded_data_file, 'r') as tar:
            tar.extractall(data_dir)
        print('Removing downloaded file ...')
        downloaded_data_file.unlink()<jupyter_output><empty_output><jupyter_text>Display list of extracted data files<jupyter_code>for entry in glob.glob(data_dir_name + "/**/*", recursive=True):
    print(entry)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10708469055374593, 'fraction_numerical': 0.0036644951140065146, 'mean_word_length': 3.8366141732283463, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '125699', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 783, 'n_tokens_neox': 755, 'n_words': 198, 'path': 'pipelines/dax_noaa_weather_data/load_data.ipynb', 'repo_name': 'ptitzler/examples', 'size': '2456'}