yay 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 code
Give unique code to street that can be looked up
What schools are in the area?
Booking system for school parcel pickup
Send parcels to every school in the country.
How to qualify for Bulk Mail discounts
To 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’s a quick rundown on how to address all your mail so it’s processed and delivered by New Zealand Post in the fastest possible time – and gets delivered to the right address, whether it’s a street address with a suburb and town, Rural Delivery address, New Zealand Post PO Box or Private Bag. The brochure covers every type of postal address, from apartments to farms, and includes handy examples of how to get your addressing right. If you’d like more detailed information on addressing standards, check out our full ‘Address Standards’ publication, which you can find at www.nzpost.co.nz/addressing Addresses in New Zealand – how they work Line Content Examples Reference This contains FreePost or other reference information, such as a customer account number. It’s mandatory for non-approved FreePost mail. Customer 767676 FreePost 2354 Recipient The name of the person and/or organisation to whom you’re addressing the mail. You can split this information over several lines. (See ‘Basic rural addresses’ and ‘PO Box, Private Bag and Counter Delivery addresses’ for situations where this line is mandatory.) Mrs S Jones The Carpet Factory Unit A unit (flat, suite etc) and/or floor. It can also include a building name. This line is mandatory if the floor detail is needed to identify the delivery point. It’s not used for PO Box, Private Bag and Counter Delivery addresses. Level 2, Mason House Suite 10, Mason House Flat 2, Mason House Building name The building name is required on this line by itself, only if there’s no known street number for the address. It’s not used for PO Box, Private Bag and Counter Delivery addresses. Mason House Delivery Mandatory Urban and rural addresses must include the street name. This line can also contain: • a street number and letter (alpha) before the street name • a unit and unit separator ‘/’ before the street number • the street type and/or street direction after the street name. Delivery Service addresses must contain one of ‘PO Box’, ‘Private Bag’, ‘Response Bag’, ‘CMB’ (Community Mail Box), ‘Counter Delivery’, or ‘Poste Restante’. This is followed by the delivery service identifier (usually a number) if New Zealand Post has allocated one. 19A Buckley Road 2B/54 Terrace Street 12 Sydney Street North PO Box 23226 Private Bag 39990 Suburb The suburb line may contain: • the suburb name for an urban address, or • ‘RD’ followed by the RD number for rural or rural CMB addresses, or • the box lobby for a PO Box address, or • the PostShop or PostCentre name for a Counter Delivery address. ‘Basic urban addresses’, ‘Basic rural addresses’ and ‘PO Box, Private Bag and Counter Delivery addresses’ cover situations where the suburb line is mandatory or not used
Sort mail by postcode. Returns all mail that needs to be delivered.
Sort by City, City + Suburb etc..
Lookup by address id
You 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 Chart
Pace - Split smaller towns up.
Track parcel/letter via webcam.
Lat/Lng of postboxes. Delivery drones pickup from postboxes and drop off to major depos.
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [5]:
import json
import shutil
import requests
import svgwrite
import arrow
import bs4
In [ ]:
In [ ]:
In [6]:
opjsres = open('/home/wcmckee/github/nzpostad.json', 'r')
In [7]:
opjrd = opjsres.read()
In [8]:
nzpod = json.loads(opjrd)
In [9]:
nzpod
Out[9]:
In [10]:
nzpaddy = nzpod['addresses']
In [11]:
nzplen = len(nzpod['addresses'])
In [12]:
nzplen
Out[12]:
In [13]:
streetstc = list()
In [14]:
stbla = list()
In [15]:
for nzp in range(0, nzplen):
nzitm = (nzpaddy[nzp])
streetstc.append(nzitm['full_address'])
In [16]:
for sts in streetstc:
stbla.append(sts.split(','))
In [17]:
strlisz = list()
In [ ]:
In [18]:
for stb in stbla:
for st in stb:
print(st)
strlisz.append(st)
In [19]:
set(strlisz)
Out[19]:
In [ ]:
In [ ]:
In [20]:
stbla[0][0]
Out[20]:
In [21]:
stbla[0][1]
Out[21]:
In [22]:
stbla[0][2]
Out[22]:
In [23]:
opsuccessad = open('/home/wcmckee/github/nzpostsuccess.json', 'r')
In [24]:
opsucrd = opsuccessad.read()
In [25]:
opjslo = json.loads(opsucrd)
In [118]:
addypocde = opjslo['address']['postcode']
In [122]:
adpoz = addypocde[0]
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [27]:
opja = opjslo['address']
In [28]:
opja['street_number']
Out[28]:
In [29]:
opja['street']
Out[29]:
In [30]:
opja['street_type']
Out[30]:
In [31]:
opja['suburb']
Out[31]:
In [32]:
adcit = opja['city']
In [33]:
opja['postcode']
Out[33]:
In [34]:
adcit
Out[34]:
In [35]:
opja['country']
Out[35]:
In [36]:
fulladdress = (str(opja['street_number']) + ' ' + opja['street'] + ' ' + opja['street_type'] +', ' + opja['suburb'] + ', ' + adcit + ' ' + str(opja['postcode']) + ', ' + opja['country'])
In [37]:
fulladdress
Out[37]:
In [38]:
opja['depot_name']
Out[38]:
In [39]:
latad = opja['latitude']
In [40]:
longad = opja['longitude']
In [41]:
latad
Out[41]:
In [42]:
longad
Out[42]:
In [43]:
mapk = open('/home/wcmckee/github/mapkey.txt', 'r')
In [44]:
mapkrd = mapk.read()
In [41]:
reqimg = 'http://www.mapquestapi.com/staticmap/v4/getmap?key=' + mapkrd + '&size=400,200&zoom=10¢er=' + str(latad) + ',' + str(longad)
In [42]:
rmnz = reqimg.replace('\n', '')
In [123]:
fuladrm = fulladdress.replace(', ', '')
In [124]:
fulrmno = fuladrm.replace(' ', '')
In [125]:
fulrmno
Out[125]:
In [128]:
opsavl = open('/home/wcmckee/Downloads/nzpost/postcode/' + adpoz + '/' + fulrmno + '.json', 'w')
In [131]:
opsavl.read
Out[131]:
In [ ]:
In [46]:
mapdir = '/home/wcmckee/nzpost/maps/'
In [47]:
addysvg = '/home/wcmckee/nzpost/addysvg/'
In [46]:
opserv = open('/home/wcmckee/github/nzpostoption.json', 'r')
In [47]:
optprd = opserv.read()
In [48]:
weighrate = json.loads(optprd)
In [49]:
lenweigh = len(weighrate)
In [50]:
lenweigh
Out[50]:
In [51]:
for lenwe in range(0, lenweigh):
print(weighrate['services'][lenwe]['price_excluding_gst'])
In [ ]:
In [52]:
weighrate
Out[52]:
In [53]:
weicar = weighrate['services'][0]['carrier']
In [ ]:
In [54]:
weiprg = weighrate['services'][0]['price_including_gst']
In [ ]:
In [55]:
weiprn = weighrate['services'][0]['price_excluding_gst']
In [56]:
waipa = (weicar + ' ' + str(weiprn) + ' ' + str(weiprg))
In [57]:
waipa
Out[57]:
In [58]:
weighaddon = weighrate['services'][0]['addons']
In [59]:
lenweia = len(weighaddon)
In [60]:
lenweia
Out[60]:
In [61]:
for lenwa in range(0, lenweia):
print (weighaddon[lenwa])
In [62]:
foxaddon = list()
In [63]:
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)
In [64]:
foxaddon
Out[64]:
In [65]:
weighcarry = weighrate['services'][0]['carrier']
In [66]:
weighcarry
Out[66]:
In [67]:
lengoxa = len(foxaddon)
In [ ]:
In [68]:
derbdict = dict()
In [69]:
for dezba in range(lengoxa):
print (dezba)
for dez in foxaddon:
derbdict.update({dezbd : dez})
In [70]:
foxaddon
Out[70]:
In [71]:
for dez in foxaddon:
for dezba in range(lengoxa):
print (dezba)
derbdict.update({dezba : dez})
In [ ]:
In [72]:
derbdict
Out[72]:
In [73]:
myflis
Out[73]:
In [74]:
weighrate['services'][0]
Out[74]:
In [75]:
oppizza = open('/home/wcmckee/github/pizzadelivpost.json', 'r')
In [ ]:
In [ ]:
In [76]:
pizrd = oppizza.read()
In [77]:
nowtime = arrow.now()
In [78]:
str(nowtime.datetime)
Out[78]:
In [ ]:
In [79]:
adval = dict({'address': fulladdress, 'datetime' : str(nowtime.datetime)})
In [80]:
adval
Out[80]:
In [81]:
json.loads(pizrd)['requests']
Out[81]:
In [82]:
opnzpobook = open('/home/wcmckee/github/nzpostbooking.json', 'r')
In [83]:
rdnzpobook = opnzpobook.read()
Client is school - contact is school email is schools email, phone, fax, website
city is school
In [ ]:
In [84]:
pobookj = json.loads(rdnzpobook)
In [85]:
popickad = pobookj['pickup_address']
In [88]:
popickad
Out[88]:
In [89]:
popickad['location_contact']
Out[89]:
In [90]:
popickad['company']
Out[90]:
In [91]:
popickad['building']
Out[91]:
In [92]:
popickad['street_number_name']
Out[92]:
In [93]:
popickad['city']
Out[93]:
In [94]:
popickad['postcode']
Out[94]:
In [95]:
popickad['suburb']
Out[95]:
In [96]:
popickad['location_phone']
Out[96]:
In [97]:
popickad
Out[97]:
In [98]:
popickad
Out[98]:
In [99]:
popickad['building']
Out[99]:
In [ ]:
In [ ]:
In [100]:
podattim = pobookj['pickup_date_time']
In [101]:
podattim
Out[101]:
In [102]:
arpick = arrow.get(podattim)
In [103]:
str(arpick.weekday())
Out[103]:
In [104]:
'delieverwhen' : str(arpick.humanize())
In [105]:
str(arpick.for_json())
Out[105]:
In [106]:
str(arpick.humanize())
Out[106]:
In [107]:
str(arpick.isoweekday())
Out[107]:
In [108]:
str(arpick.isocalendar())
Out[108]:
In [109]:
str(arpick.isoformat())
Out[109]:
In [ ]:
In [110]:
pobookj['caller']
Out[110]:
In [111]:
pobookj['client_contact']
Out[111]:
In [112]:
pobookj['email_address']
Out[112]:
In [113]:
arrows.pobookj['message_date_time']
In [114]:
pobookj['city']
In [115]:
pobokdead = pobookj['delivery_address']
In [116]:
pocom = pobokdead['company']
In [117]:
pobuil = pobokdead['building']
In [118]:
poflo = pobokdead['floor']
In [119]:
postnuma = pobokdead['street_number_name']
In [120]:
posub = pobokdead['suburb']
In [121]:
pocity = pobokdead['city']
In [122]:
popcd = pobokdead['postcode']
In [123]:
poem = pobokdead['email_address']
In [124]:
poinstr = pobokdead['instructions']
In [125]:
poinstr
Out[125]:
In [126]:
poloccon = pobokdead['location_contact']
In [ ]:
In [127]:
polocph = pobokdead['location_phone']
In [128]:
fuldevad = (poloccon + ' ' + pocom + ', ' + pobuil + ' ' + postnuma + ', ' + posub + ', ' + pocity + ' ' + popcd + ', ' + polocph + ', ' + poem + ', ' + poinstr)
In [129]:
fuldevad
Out[129]:
In [ ]:
In [130]:
opcourpo = open('/home/wcmckee/github/nzpostcourbook.json', 'r')
In [131]:
rdcoupo = opcourpo.read()
In [132]:
conrn = rdcoupo.replace('\n', '')
In [133]:
conrn
Out[133]:
In [ ]:
In [134]:
json.loads(conrn)
In [86]:
import requests
import xmltodict
In [ ]:
In [ ]:
In [87]:
bitcoinconv = requests.get('http://coinmill.com/rss/BTC_NZD.xml')
In [88]:
xmltodict.parse(bitcoinconv.text)
Out[88]:
In [89]:
import os
In [90]:
opschrol = ('/home/wcmckee/ccschol/')
In [91]:
os.listdir(opschrol)
In [92]:
opstoreloc = open('/home/wcmckee/github/nzpoststoreloc.json', 'r')
In [93]:
nzpstord = opstoreloc.read()
In [151]:
nzpstdj = json.loads(nzpstord)
In [ ]:
In [153]:
nzpstdj['address']
Out[153]:
Give stores an email address and their own domain, nikola blog
In [155]:
nzpstdj['description']
Out[155]:
In [156]:
nzpstdj['hours']
Out[156]:
In [ ]:
nzpstdj
In [157]:
nzpstdj['lat']
Out[157]:
In [161]:
nzpstdj['lng']
Out[161]:
In [163]:
nzpstdj['kiwibank_personal_region']
Out[163]:
In [ ]:
In [94]:
reqkinrt = requests.get('https://www.kiwibank.co.nz/locations/indexes/northland')
In [95]:
rdkiwiloc = reqkinrt.text
In [96]:
bskiwloc = bs4.BeautifulSoup(rdkiwiloc)
In [97]:
kiwitrre = bskiwloc.find_all('tr')
Parse the locations href string.
id : 58062
slug : dargaville-postshop
title : Dargaville PostShop
lat : 45
long : 130.5323432
ipaddress : 192.168.5.10 (firewall) - list of all machines and ipaddress. Get hostnames from colour-lovers
email : dargaville-postshop@nzpost.co.nz
website : dargaville-postshop.nzpost.co.nz
publickey : SSH-RSA AAAAA345332463454323432
cointwaller : RRSAAEEEE453635435235 (bitcoin wallet) - wallet details
openhours : 0700 2100 7 DAYS
In [ ]:
In [ ]:
In [100]:
kiwitrre
Out[100]:
Lookup lat/lng of kiwibank atm/postshop results.
In [ ]:
In [113]:
for kiwiz in kiwitrre:
print(kiwiz.text)
kifinl = (kiwiz.find_all('a'))
for kif in kifinl:
print(kif.text)
print(kif)
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [187]:
import xmltodict
In [ ]:
In [198]:
opstorehr = open('/home/wcmckee/github/auspostdelivtime.xml', 'r')
In [199]:
stordz = opstorehr.read()
In [200]:
stordz
Out[200]:
In [201]:
opsth = xmltodict.parse(stordz)
In [207]:
daydevly = opsth['DeliveryTimeslots']['DayTimeslot']
In [209]:
daydevly['Weekday']
Out[209]:
In [211]:
daydevly['WeekdayDescription']
Out[211]:
In [214]:
datimeper = daydevly['TimePeriod']
In [218]:
numdetim = len(datimeper)
In [225]:
for numd in range(0, numdetim):
print(datimeper[numd]['StartTime'])
print(datimeper[numd]['EndTime'])
In [141]:
response = requests.get(rmnz, stream=True)
with open(mapdir + fulrmno + '.png', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
In [142]:
dwg = svgwrite.Drawing(addysvg + fulrmno)
dwg.add(dwg.text(adcit, insert=(0, 0.2), fill='black'))
dwg.save()
In [143]:
opjsf = dict({'FullAddress' : fulladdress, 'AddressMap' : mapdir + fulrmno + '.png', 'AddressLong' : latad, 'AddressLat' : longad, 'AddressText' : addysvg + fulrmno + '.svg', 'delieverwhen' : str(arpick.humanize()), 'fulldeliver' : fuldevad})
In [144]:
opjsf
Out[144]: