source: main/waeup.sirp/branches/ulif-fasttables/src/waeup/sirp/jambtables/README.txt @ 5241

Last change on this file since 5241 was 5239, checked in by uli, 14 years ago

Renable jambtable examples and add import_datetime examples.

File size: 2.1 KB
Line 
1JAMB registration numbers
2*************************
3
4:doctest:
5
6JAMB data is stored in a JAMBDataTable.
7
8We can import JAMB registration data from a regular CSV file:
9
10    >>> datafile = 'jambsample.csv'
11    >>> open(datafile, 'wb').write(
12    ... '''reg_no,fst_sit_fname,lastname,firstname,middlenames,sex,date_of_birth,jamb_state,jamb_lga,course1,screening_date,screening_venue,entry_session,screening_type
13    ... 91100546DD,ISUOSUO MOSES ODOMERO,ISUOSUO,MOSES,ODOMERO,M,25/5/1982,DEL,ISO-S,BSCPOL,2009/09/25 09:00:00 GMT+1,REPRINT SLIP AS FROM WED 23/09/2009,9,pde
14    ... 91111834CC,DURUIHEOMA AUGUSTINA ADANNA,DURUIHEOMA,AUGUSTINA,ADANNA,F,15/4/1986,IMO,MBAIT,BSCPOL,2009/09/25 09:00:00 GMT+1,REPRINT SLIP AS FROM WED 23/09/2009,9,pde
15    ... 91109351AC,ARISERE EBIKEBUNA COMFORT,ARISERE,EBIKEBUNA,COMFORT,F,6/1/1984,EDO,OV-SW,BSCPOL,2009/09/25 09:00:00 GMT+1,REPRINT SLIP AS FROM WED 23/09/2009,9,pde
16    ... ''')
17
18Now we create a JAMBDataTable and import the data:
19
20    >>> from waeup.sirp.jambtables import JAMBDataTable
21    >>> table = JAMBDataTable()
22    >>> len(list(table))
23    0
24
25    >>> table.importFromCSV(datafile)
26    >>> len(list(table))
27    3
28
29We can get the entries from the table as an iterator:
30
31    >>> from pprint import pprint
32    >>> entries = [x for x in table]
33    >>> pprint(entries)
34    [{'course1': u'BSCPOL',
35      'date_of_birth': datetime.date(1982, 5, 25),
36      'entry_session': '9',
37      'firstname': u'MOSES',
38      'fst_sit_fname': u'ISUOSUO MOSES ODOMERO',
39      'jamb_lga': u'ISO-S',
40      'jamb_state': u'DEL',
41      'lastname': u'ISUOSUO',
42      'middlenames': u'ODOMERO',
43      'reg_no': u'91100546DD',
44      'screening_date': u'2009/09/25 09:00:00 GMT+1',
45      'screening_type': u'pde',
46      'screening_venue': u'REPRINT SLIP AS FROM WED 23/09/2009',
47      'sex': u'M'},
48     {...},
49     {...}]
50
51We can also get a datetime stamp, that tells, when the table was
52imported. This could help with maintaining old tables:
53
54    >>> table.import_datetime
55    datetime.datetime(..., ..., ..., ..., ..., ..., ...)
56   
57
58We can delete the table:
59
60    >>> del JAMBDataTable
61
62Clean up:
63
64    >>> import os
65    >>> os.unlink(datafile)
Note: See TracBrowser for help on using the repository browser.