hamentorwrite

Hamilton Mentor Write

Script to write login of Hamilton Computer Mentors.

Config file contains default hours (start time, end time), name, library, Looks up date. Asks for amount of people helped, type of help (tags - choose from popular choices), device helped with (tags - choose from popular choices), and comments.

Could the config file just be a json object?

In [69]:
import arrow
import json
import os
In [70]:
arnow = arrow.now()
In [71]:
thedate = str(arnow.date())
In [72]:
str(arnow.time())
Out[72]:
'15:21:22.687083'
In [73]:
startime = ('13:00:00')
In [74]:
endtime = ('15:00:00')
In [75]:
myname = input('Name: ')
Name: William
In [76]:
mylib = ('GP')
In [77]:
typehelp = input('Type of help given: ')
Type of help given: helped with cv
In [78]:
devtype = input('Device: ')
Device: tablet
In [79]:
fincomments = input('Comments: ')
Comments: today i helped lots of people
In [80]:
anodict = dict()
In [81]:
defdict = {'name' : myname, 'startdatetime' : thedate + ' ' + startime, 'enddatetime' : thedate + ' ' + endtime, 
           'library' : 'GP', 'help count' : int(pplhelped), 'help' : typehelp, 'device' : devtype, 
           'comments': fincomments}
In [82]:
valddict = defdict.values()
In [83]:
valddict
Out[83]:
dict_values(['GP', 'tablet', 3, 'William', 'helped with cv', '2015-10-14 13:00:00', 'today i helped lots of people', '2015-10-14 15:00:00'])

What I want to do is take this dict and create columns out of the keys and rows of values under the column.

Could this perhaps works as an api - saving the latest as 0.

Create a json file that the json object is saved to. This script opens the json file and appends the new json object to it. It counts how many are already in the json file and assigns a +1 to it.

For now could just check hamcommen for amount of json objects and create a new +1

Not happy with creating lots of .json files in the folder, but whatever this will do for now.

In [84]:
lishamcomen = os.listdir('/home/wcmckee/hamcommen/')
In [85]:
lecomen = len(lishamcomen)
In [86]:
newlecom = lecomen + 1
In [90]:
wthamcom = open('/home/wcmckee/hamcommen/index' + str(newlecom) + '.json', 'w')
In [91]:
wthamcom.write(json.dumps(defdict))
Out[91]:
222
In [93]:
wthamcom.close()

Comments

Comments powered by Disqus