nikoladu

Nikoladu

Script to take json object of ministry of education jobs and create Nikola blog posts - rst and meta files.

In [1]:
#import nikola

import requests
import json
import pandas
In [ ]:
 
In [2]:
opedu = open('/home/wcmckee/github/wcmckee.com/output/minedujobs/index.json', 'r')
In [3]:
minjob = opedu.read()
In [4]:
dicminj = json.loads(minjob)
In [5]:
ldic = len(dicminj)
In [ ]:
 
In [7]:
catlis = list()

loclis = list()
datlis = list()
jobti = list()
In [ ]:
 
In [8]:
numdic = dict()
In [ ]:
 
In [9]:
for ldi in range(ldic):
    dicjob = dict()
    catedi = (dicminj[str(ldi)]['Category'])
    locdi = (dicminj[str(ldi)]['Location'])
    datdi = (dicminj[str(ldi)]['Date Advertised'])
    pandatz = pandas.to_datetime(datdi)
    pdate = pandatz.date()
    titdi = (dicminj[str(ldi)]['Job Title'])
    
    jobref = (dicminj[str(ldi)]['Job Reference'])
    jorefd = jobref[4:]
    #print (jorefd)
    
    skildi = (dicminj[str(ldi)]['lidocend'])
    
    #for ski in skildi:
        #print (ski)
        #for sk in ski:
            #print (sk)
    #print (titdi + '\n' + skildi)
            
            
    
    opmetf = open('/home/wcmckee/minstryofedu/posts/' + jorefd + '.meta', 'w')
    opmetf.write(jorefd + '\n' + jorefd + '\n' + str(pdate) + ' ' + str('09:00:00') + '\n' + catedi + ', ' + locdi)
    opmetf.close()
    
    oprstfi = open('/home/wcmckee/minstryofedu/posts/' + jorefd + '.rst', 'w')
    oprstfi.write(titdi)
    for ski in skildi:
        #print (ski)
        #for sk in ski:
        #    print (sk)
        oprstfi.write(str(ski))
    
    oprstfi.close()



    dicjob.update({'Category' : catedi, 'Date Advertised' : str(pdate), 'Job Title' : titdi,
    'Location' : locdi, 'Job Reference' : jobref})
    
    numdic.update({ldi : dicjob})
    #numdic.update({ldi : dicjob})
    
    loclis.append(locdi)
    datlis.append(datdi)
    jobti.append(titdi)
    
    nedicf = dicjob.copy()
    nedicf.update(nedicf)
    
    numdic.update({ldi : nedicf})
    
    #if 'education' in catedi:
    #    print (catedi)

        
In [11]:
allpda = list()
In [ ]:
 
In [12]:
for dal in datlis:
    allpdata = pandas.to_datetime(dal)
    allpda.append(allpdata)
In [15]:
datsli = list(set(datlis))
In [16]:
import arrow
In [17]:
panlis = list()
In [18]:
for dalz in datsli:
    print (dalz)
    panlis.append(pandas.to_datetime(dalz))
    
21-AUG-15
12-AUG-15
02-SEP-15
01-SEP-15
28-AUG-15
17-AUG-15
13-AUG-15
20-AUG-15
31-AUG-15
26-AUG-15
19-AUG-15
14-AUG-15
25-AUG-15
In [19]:
for panl in panlis:
    #print (panl.dayofweek)
    print (panl.dayofyear)
    print (panl.date())
233
2015-08-21
224
2015-08-12
245
2015-09-02
244
2015-09-01
240
2015-08-28
229
2015-08-17
225
2015-08-13
232
2015-08-20
243
2015-08-31
238
2015-08-26
231
2015-08-19
226
2015-08-14
237
2015-08-25
In [20]:
catsli = list(set(catlis))
In [21]:
locset = list(set(loclis))
In [22]:
locset
Out[22]:
['Wellington',
 'Otago',
 'Canterbury',
 'Bay of Plenty',
 'Gisborne',
 'Manawatu',
 'Auckland',
 'Whangarei',
 'Napier',
 'Whanganui']

Comments

Comments powered by Disqus