<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Use the WMATA api to get station locations for each line
LineCode string
Two-letter line code abbreviation
Step2:  Make a function for importing the station info for each line
Step3:  Import the data for each line
Step4:  Turn list of dict's into dic with line (key) and stations (value)
Step5:  Use Pickel to save the dictionary of lines with the station locations
<ASSISTANT_TASK:>
Python Code:
import http.client, urllib.request, urllib.parse, urllib.error, base64
import urllib
import json
import pickle
Explanation: Use the WMATA api to get station locations for each line
LineCode string
Two-letter line code abbreviation:
RD - Red
YL - Yellow
GR - Green
BL - Blue
OR - Orange
SV - Silver
End of explanation
def metro_line_import(line):
    Import station data from WMATA API and format it as a dictionary with staion name as the key and the
    [latitude, longitude] as the values
    headers = {
    # Request headers
    'api_key': '7f97903f83b24fcaa6dcc929bdb73437',
    }
    params = urllib.parse.urlencode({
        # Request parameters
        'LineCode': line,
    })
    try:
        conn = http.client.HTTPSConnection('api.wmata.com')
        conn.request("GET", "/Rail.svc/json/jStations?%s" % params, "{body}", headers)
        response = conn.getresponse()
        data = response.read()
        #print(data)
        conn.close()
        data_js = json.loads(data)
        line_dic = dict()
        for ii in range(len(data_js['Stations'])):
            line_dic[data_js['Stations'][ii]['Name']] = [data_js['Stations'][ii]['Lat'], data_js['Stations'][ii]['Lon']]
        #print(line_dic)
    except Exception as e:
        print("[Errno {0}] {1}".format(e.errno, e.strerror))
    return line_dic
Explanation: Make a function for importing the station info for each line
End of explanation
lines = ['RD', 'YL', 'GR','BL', 'OR', 'SV']
line_stations = []
for ii in range(len(lines)):
    line_stations.append(metro_line_import(lines[ii]))
Explanation: Import the data for each line
End of explanation
station_data = dict()
for ii in range(len(lines)):
    station_data[lines[ii]] = line_stations[ii]
Explanation: Turn list of dict's into dic with line (key) and stations (value)
End of explanation
pickle.dump( station_data, open( "station_data.p", "wb" ) )
station_data['RD']['Silver Spring']
Explanation: Use Pickel to save the dictionary of lines with the station locations
End of explanation
<END_TASK>