<jupyter_start><jupyter_text>Weather Data ProjectWe'll experiment with historical weather data going back 50 years and sometimes more. We are going to do a lot. We are going to load station and temperature data from publicly available text files from the National Oceanic and Atmosphere Administration.We're going to plot temperature data. And we realize to do so effectively, you first need to integrate missing data and to smooth them. We will compute the daily records at the given location and, finally, for your challenge, I will ask you to compare the warmest year of a cold location with the coldest year of a warm one. **Downloading and Parsing data files**1. Download a file over FTP2. parse a space-separated file into a python dict<jupyter_code>import numpy as np
import matplotlib.pyplot as pp
import seaborn
% matplotlib inline
# To download file using urllib

import urllib.request

urllib.request.urlretrieve('ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/ghcnd-stations.txt','stations.txt')  #second argument local name of the file
#Use readlines and use slicing to select the first few items in the list.

open('stations.txt','r').readlines()[:10]<jupyter_output><empty_output><jupyter_text>Some stations are tagged as GSN. That's the GCOS Surface Network.We'll concentrate on those. So let's gather some data from this text file. We go through, read all the lines. We skip those that do not have the GSN keywords.And we just collect the station names in a dictionary indexed by the station code.<jupyter_code>stations = {}

for line in open('stations.txt','r'):   #iterate through each line as strings
    if 'GSN' in line:
        fields = line.split()   #split line/string with GSN by whitespaces and assign resulting fields to a python list
        
        #use first item i.e, the station code as the key
        # use fifth and following items for the name of station, joined using a space between them
        
        stations[fields[0]] = ' '.join(fields[4:])
len(stations)<jupyter_output><empty_output><jupyter_text>we should really concentrate on a few only. So let's write a function that lets us look for interesting patterns in the station name. We'll call it findstation(). And let's build a dictionary **found** using a comprehension of the station codes and names where the pattern that we're interested in is found within the name. Let's just print it.<jupyter_code>def findstation(s):
    found = {code: name for code,name in stations.items() if s in name}
    print(found)
findstation('LIHUE')
findstation('SAN DIEGO')
findstation('MINNEAPOLIS')
findstation('IRKUTSK')<jupyter_output>{'RSM00030710': 'IRKUTSK GSN 30710'}
{'fraction_non_alphanumeric': 0.07228915662650602, 'fraction_numerical': 0.007906626506024096, 'mean_word_length': 4.546972860125261, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '140327', 'license': 'MIT', 'n_tokens_mistral': 759, 'n_tokens_neox': 726, 'n_words': 352, 'path': 'NumPy - Weather data Project/01 stations.ipynb', 'repo_name': 'AryaDevops/Python-for-DataScience', 'size': '2656'}