<jupyter_start><jupyter_text>nzpostaddyyay maps, something I haven't really used before. Good to try something new. Using some demo examples from nz post. Examples are printed below. script to search for addresses.Gets address from nzpost then displays static map from mapquestapi.Lookup lat long against high speed internet access.Create svg files from address and save to folder and add to json object.Check for pizza options. People need pizza right?Is this house on the market.Scan for open wireless networks.Convert full country name to country codeGive unique code to street that can be looked up What schools are in the area? Booking system for school parcel pickupSend parcels to every school in the country. How to qualify for Bulk Mail discountsTo qualify for Bulk Mail discounts, there are a few things you’ll need to consider:    Are the addresses in your database accurate against the Postal Address File (PAF)? Refer to validate customer addresses for further information.    Have you used the correct address and envelope format and layout?    Are your items sorted by postcode?Getting your mail If you want your mail to reach its destination as quickly and accurately as possible, this brochure is for you!It’saquickrundownonhowtoaddressallyourmailsoit’sprocessedanddeliveredbyNewZealandPostinthefastestpossibletime–andgetsdeliveredtotherightaddress,whetherit’sastreetaddresswithasuburbandtown,RuralDeliveryaddress,NewZealandPostPOBoxorPrivateBag.Thebrochurecoverseverytypeofpostaladdress,fromapartmentstofarms,andincludeshandyexamplesofhowtogetyouraddressingright.Ifyou’dlikemoredetailedinformationonaddressingstandards,checkoutourfull‘AddressStandards’publication,whichyoucanfindatwww.nzpost.co.nz/addressingAddressesinNewZealand–howtheyworkLineContentExamplesReferenceThiscontainsFreePostorotherreferenceinformation,suchasacustomeraccountnumber.It’smandatoryfornon-approvedFreePostmail.Customer767676FreePost2354RecipientThenameofthepersonand/ororganisationtowhomyou’readdressingthemail.Youcansplitthisinformationoverseverallines.(See‘Basicruraladdresses’and‘POBox,PrivateBagandCounterDeliveryaddresses’forsituationswherethislineismandatory.)MrsSJonesTheCarpetFactoryUnitAunit(flat,suiteetc)and/orfloor.Itcanalsoincludeabuildingname.Thislineismandatoryifthefloordetailisneededtoidentifythedeliverypoint.It’snotusedforPOBox,PrivateBagandCounterDeliveryaddresses.Level2,MasonHouseSuite10,MasonHouseFlat2,MasonHouseBuildingnameThebuildingnameisrequiredonthislinebyitself,onlyifthere’snoknownstreetnumberfortheaddress.It’snotusedforPOBox,PrivateBagandCounterDeliveryaddresses.MasonHouseDeliveryMandatoryUrbanandruraladdressesmustincludethestreetname.Thislinecanalsocontain:•astreetnumberandletter(alpha)beforethestreetname•aunitandunitseparator‘/’beforethestreetnumber•thestreettypeand/orstreetdirectionafterthestreetname.DeliveryServiceaddressesmustcontainoneof‘POBox’,‘PrivateBag’,‘ResponseBag’,‘CMB’(CommunityMailBox),‘CounterDelivery’,or‘PosteRestante’.Thisisfollowedbythedeliveryserviceidentifier(usuallyanumber)ifNewZealandPosthasallocatedone.19ABuckleyRoad2B/54TerraceStreet12SydneyStreetNorthPOBox23226PrivateBag39990SuburbThesuburblinemaycontain:•thesuburbnameforanurbanaddress,or•‘RD’followedbytheRDnumberforruralorruralCMBaddresses,or•theboxlobbyforaPOBoxaddress,or•thePostShoporPostCentrenameforaCounterDeliveryaddress.‘Basicurbanaddresses’,‘Basicruraladdresses’and‘POBox,PrivateBagandCounterDeliveryaddresses’coversituationswherethesuburblineismandatoryornotusedSort mail by postcode. Returns all mail that needs to be delivered.Sort by City, City + Suburb etc..Lookup by address idYou are loged into system to pickup parcels at 0700 that will be dropped at Wellington depo at 0725. 0730 0755 0800 0825 0830 0855. Have drone at major depos that deliver. Scan barcode to check parcel out.Recieve all written mail via email. Postal letters can have barcode on that scans for a doc. gpg encrupt that has passphase/password on that only the person recieving it has.Give all postal addresses public/private keys to open their mail.Pace Auckland Zone ChartPace - Split smaller towns up.Track parcel/letter via webcam.Lat/Lng of postboxes. Delivery drones pickup from postboxes and drop off to major depos.<jupyter_code>import json
import shutil
import requests
import svgwrite
import arrow
import bs4

opjsres = open('/home/wcmckee/github/nzpostad.json', 'r')
opjrd = opjsres.read()
nzpod = json.loads(opjrd)
nzpod
nzpaddy = nzpod['addresses']
nzplen = len(nzpod['addresses'])
nzplen
streetstc = list()
stbla = list()
for nzp in range(0, nzplen):
    nzitm = (nzpaddy[nzp])
    streetstc.append(nzitm['full_address'])
    
    
for sts in streetstc:
    stbla.append(sts.split(','))
strlisz = list()
for stb in stbla:
    for st in stb:
        print(st)
        strlisz.append(st)
set(strlisz)
stbla[0][0]
stbla[0][1]
stbla[0][2]
opsuccessad = open('/home/wcmckee/github/nzpostsuccess.json', 'r')
opsucrd = opsuccessad.read()
opjslo = json.loads(opsucrd)
addypocde = opjslo['address']['postcode']
adpoz = addypocde[0]
opja = opjslo['address']
opja['street_number']
opja['street']
opja['street_type']
opja['suburb']
adcit = opja['city']
opja['postcode']
adcit
opja['country']
fulladdress = (str(opja['street_number']) + ' ' + opja['street'] +  ' ' + opja['street_type'] +', ' + opja['suburb'] + ', ' + adcit + ' ' + str(opja['postcode']) + ', ' + opja['country'])
fulladdress
opja['depot_name']
latad = opja['latitude']
longad = opja['longitude']
latad
longad
mapk = open('/home/wcmckee/github/mapkey.txt', 'r')
mapkrd = mapk.read()
reqimg = 'http://www.mapquestapi.com/staticmap/v4/getmap?key=' + mapkrd + '&size=400,200&zoom=10&center=' + str(latad) + ',' + str(longad) 
rmnz = reqimg.replace('\n', '')
fuladrm = fulladdress.replace(', ', '')
fulrmno = fuladrm.replace(' ', '')
fulrmno
opsavl = open('/home/wcmckee/Downloads/nzpost/postcode/' + adpoz + '/' + fulrmno + '.json', 'w')
opsavl.read
mapdir = '/home/wcmckee/nzpost/maps/'
addysvg = '/home/wcmckee/nzpost/addysvg/'
opserv = open('/home/wcmckee/github/nzpostoption.json', 'r')
optprd = opserv.read()
weighrate = json.loads(optprd)
lenweigh = len(weighrate)
lenweigh
for lenwe in range(0, lenweigh):
    print(weighrate['services'][lenwe]['price_excluding_gst'])
weighrate
weicar =  weighrate['services'][0]['carrier']
weiprg = weighrate['services'][0]['price_including_gst']

weiprn = weighrate['services'][0]['price_excluding_gst']
waipa = (weicar + ' ' + str(weiprn) + ' ' + str(weiprg))
waipa
weighaddon = weighrate['services'][0]['addons']
lenweia = len(weighaddon)
lenweia
for lenwa in range(0, lenweia):
    print (weighaddon[lenwa])
foxaddon = list()
for lenwa in range(0, lenweia):
    weaddonco = (weighaddon[lenwa]['addon_code'])
    weaddondescp = (weighaddon[lenwa]['description'])
    weighaddongst =  (weighaddon[lenwa]['price_including_gst'])
    weighmantor = (weighaddon[lenwa]['mandatory'])
    myflis = (weaddonco + ', ' + weaddondescp + ', ' + str(weighmantor) + ', ' + str(weighaddongst))
    foxaddon.append(myflis)

foxaddon
weighcarry = weighrate['services'][0]['carrier']
weighcarry
lengoxa = len(foxaddon)
derbdict = dict()
for dezba in range(lengoxa):
    print (dezba)
    for dez in foxaddon:
        derbdict.update({dezbd : dez})
foxaddon
for dez in foxaddon:
    for dezba in range(lengoxa):
        print (dezba)
        derbdict.update({dezba : dez})
derbdict
myflis
weighrate['services'][0]
oppizza = open('/home/wcmckee/github/pizzadelivpost.json', 'r')
pizrd = oppizza.read()
nowtime = arrow.now()
str(nowtime.datetime)
adval = dict({'address': fulladdress, 'datetime' : str(nowtime.datetime)})
adval
json.loads(pizrd)['requests']
opnzpobook = open('/home/wcmckee/github/nzpostbooking.json', 'r')
rdnzpobook = opnzpobook.read()<jupyter_output><empty_output><jupyter_text>Client is school  - contact is schoolemail is schools email, phone, fax, websitecity is school<jupyter_code>pobookj = json.loads(rdnzpobook)
popickad = pobookj['pickup_address']
popickad
popickad['location_contact']
popickad['company']
popickad['building']
popickad['street_number_name']
popickad['city']
popickad['postcode']
popickad['suburb']
popickad['location_phone']
popickad
popickad
popickad['building']
podattim = pobookj['pickup_date_time']
podattim
arpick = arrow.get(podattim)
str(arpick.weekday())
'delieverwhen' : str(arpick.humanize())
str(arpick.for_json())
str(arpick.humanize())
str(arpick.isoweekday())
str(arpick.isocalendar())
str(arpick.isoformat())
pobookj['caller']
pobookj['client_contact']
pobookj['email_address']
arrows.pobookj['message_date_time']
pobookj['city']
pobokdead = pobookj['delivery_address']
pocom = pobokdead['company']
pobuil = pobokdead['building']
poflo = pobokdead['floor']
postnuma = pobokdead['street_number_name']
posub = pobokdead['suburb']
pocity = pobokdead['city']
popcd = pobokdead['postcode']
poem = pobokdead['email_address']
poinstr = pobokdead['instructions']
poinstr
poloccon = pobokdead['location_contact']
polocph = pobokdead['location_phone']
fuldevad = (poloccon + ' ' + pocom + ', ' + pobuil + ' ' + postnuma + ', ' + posub + ', ' + pocity + ' ' + popcd + ', ' + polocph + ', ' + poem + ', ' + poinstr)
fuldevad
opcourpo = open('/home/wcmckee/github/nzpostcourbook.json', 'r')
rdcoupo = opcourpo.read()
conrn = rdcoupo.replace('\n', '')
conrn
json.loads(conrn)
import requests
import xmltodict
bitcoinconv = requests.get('http://coinmill.com/rss/BTC_NZD.xml')
xmltodict.parse(bitcoinconv.text)
import os
opschrol = ('/home/wcmckee/ccschol/')
os.listdir(opschrol)
opstoreloc = open('/home/wcmckee/github/nzpoststoreloc.json', 'r')
nzpstord = opstoreloc.read()
nzpstdj = json.loads(nzpstord)
nzpstdj['address']<jupyter_output><empty_output><jupyter_text>Give stores an email address and their own domain, nikola blog<jupyter_code>nzpstdj['description']
nzpstdj['hours']
nzpstdj
nzpstdj['lat']
nzpstdj['lng']
nzpstdj['kiwibank_personal_region']
reqkinrt = requests.get('https://www.kiwibank.co.nz/locations/indexes/northland')
rdkiwiloc = reqkinrt.text
bskiwloc = bs4.BeautifulSoup(rdkiwiloc)
kiwitrre = bskiwloc.find_all('tr')<jupyter_output><empty_output><jupyter_text>Parse the locations href string. id : 58062slug : dargaville-postshoptitle : Dargaville PostShoplat : 45long : 130.5323432ipaddress : 192.168.5.10 (firewall) - list of all machines and ipaddress. Get hostnames from colour-loversemail : <EMAIL>website : dargaville-postshop.nzpost.co.nzpublickey : SSH-RSA AAAAA345332463454323432cointwaller : RRSAAEEEE453635435235 (bitcoin wallet) - wallet detailsopenhours : 0700 2100 7 DAYS<jupyter_code>kiwitrre<jupyter_output><empty_output><jupyter_text>Lookup lat/lng of kiwibank atm/postshop results.<jupyter_code>for kiwiz in kiwitrre:
    print(kiwiz.text)
    kifinl = (kiwiz.find_all('a'))
    
    for kif in kifinl:
        print(kif.text)
        print(kif)
import xmltodict
opstorehr = open('/home/wcmckee/github/auspostdelivtime.xml', 'r')
stordz = opstorehr.read()
stordz
opsth = xmltodict.parse(stordz)
daydevly = opsth['DeliveryTimeslots']['DayTimeslot']
daydevly['Weekday']
daydevly['WeekdayDescription']
datimeper = daydevly['TimePeriod']
numdetim = len(datimeper)
for numd in range(0, numdetim):
    print(datimeper[numd]['StartTime'])
    
    print(datimeper[numd]['EndTime'])
response = requests.get(rmnz, stream=True)
with open(mapdir + fulrmno + '.png', 'wb') as out_file:
    shutil.copyfileobj(response.raw, out_file)
del response
dwg = svgwrite.Drawing(addysvg + fulrmno)
dwg.add(dwg.text(adcit, insert=(0, 0.2), fill='black'))
dwg.save()
opjsf = dict({'FullAddress' : fulladdress, 'AddressMap' : mapdir + fulrmno + '.png', 'AddressLong' : latad, 'AddressLat' : longad, 'AddressText' : addysvg + fulrmno + '.svg', 'delieverwhen' : str(arpick.humanize()), 'fulldeliver' : fuldevad})
opjsf<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11922718413693754, 'fraction_numerical': 0.013558173036183374, 'mean_word_length': 7.218662952646239, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, 'https://': 1, 'lorem ipsum': 0, 'www.': 3, 'xml': 6}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '616613', 'license': 'MIT', 'n_tokens_mistral': 4375, 'n_tokens_neox': 4162, 'n_words': 802, 'path': 'nzpostaddy.ipynb', 'repo_name': 'wcmckee/wcmckee', 'size': '11826'}