source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/jambtables/README.txt @ 5743

Last change on this file since 5743 was 5691, checked in by uli, 14 years ago

Update tests: fix import of jambtable components.

File size: 3.7 KB
RevLine 
[5235]1JAMB registration numbers
2*************************
3
[5263]4.. :doctest:
[5235]5
6JAMB data is stored in a JAMBDataTable.
7
[5243]8Creating JAMB Tables
9====================
10
[5235]11We can import JAMB registration data from a regular CSV file:
12
13    >>> datafile = 'jambsample.csv'
14    >>> open(datafile, 'wb').write(
15    ... '''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
16    ... 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
17    ... 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
18    ... 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
19    ... ''')
20
[5244]21JAMB CSV tables have to provide the following header fields in the
22first line:
23
24    >>> from pprint import pprint
[5691]25    >>> from waeup.sirp.applicants.jambtables.jambtables import JAMB_DATA_HEADERS
[5244]26    >>> JAMB_DATA_HEADERS
27    ['firstname', 'lastname', 'middlenames', 'screening_type',
28     'screening_venue', 'reg_no', 'sex', 'course1', 'jamb_state',
29     'screening_date', 'jamb_lga', 'fst_sit_fname', 'date_of_birth']
30
[5235]31Now we create a JAMBDataTable and import the data:
32
[5691]33    >>> from waeup.sirp.applicants.jambtables import JAMBDataTable
[5235]34    >>> table = JAMBDataTable()
35    >>> len(list(table))
36    0
37
38    >>> table.importFromCSV(datafile)
39    >>> len(list(table))
40    3
41
[5243]42Accessing JAMB Data
43===================
44
45Getting Entries
46---------------
47
[5235]48We can get the entries from the table as an iterator:
49
[5239]50    >>> from pprint import pprint
51    >>> entries = [x for x in table]
52    >>> pprint(entries)
53    [{'course1': u'BSCPOL',
54      'date_of_birth': datetime.date(1982, 5, 25),
55      'entry_session': '9',
56      'firstname': u'MOSES',
57      'fst_sit_fname': u'ISUOSUO MOSES ODOMERO',
58      'jamb_lga': u'ISO-S',
59      'jamb_state': u'DEL',
60      'lastname': u'ISUOSUO',
61      'middlenames': u'ODOMERO',
62      'reg_no': u'91100546DD',
63      'screening_date': u'2009/09/25 09:00:00 GMT+1',
64      'screening_type': u'pde',
65      'screening_venue': u'REPRINT SLIP AS FROM WED 23/09/2009',
66      'sex': u'M'},
67     {...},
68     {...}]
[5235]69
[5243]70Also a :meth:`keys` and :meth:`items` method are available. They both
71return an iterator.
72
73The :meth:`keys` method in action:
74
75     >>> pprint(list(table.keys()))
76     [u'91100546DD', u'91111834CC', u'91109351AC']
77
78The :meth:`items` method in action:
79
80     >>> pprint(list(table.items()))
81     [(u'91100546DD',
82      {'course1': u'BSCPOL',
83       'date_of_birth': datetime.date(1982, 5, 25),
84       'entry_session': '9',
85       'firstname': u'MOSES',
86       'fst_sit_fname': u'ISUOSUO MOSES ODOMERO',
87       'jamb_lga': u'ISO-S',
88       'jamb_state': u'DEL',
89       'lastname': u'ISUOSUO',
90       'middlenames': u'ODOMERO',
91       'reg_no': u'91100546DD',
92       'screening_date': u'2009/09/25 09:00:00 GMT+1',
93       'screening_type': u'pde',
94       'screening_venue': u'REPRINT SLIP AS FROM WED 23/09/2009',
95       'sex': u'M'}),
96     (u'91111834CC',
97      {...}),
98     (u'91109351AC',
99      {...})]
100
101A ``values()``-like behaviour cen be archieved by simply using the
102iterator.
103
104Getting JAMB Table Meta Data
105----------------------------
106
[5239]107We can also get a datetime stamp, that tells, when the table was
108imported. This could help with maintaining old tables:
[5235]109
[5239]110    >>> table.import_datetime
111    datetime.datetime(..., ..., ..., ..., ..., ..., ...)
112   
113
[5235]114We can delete the table:
115
116    >>> del JAMBDataTable
117
118Clean up:
119
120    >>> import os
121    >>> os.unlink(datafile)
Note: See TracBrowser for help on using the repository browser.