1 | JAMB registration numbers |
---|
2 | ************************* |
---|
3 | |
---|
4 | :doctest: |
---|
5 | |
---|
6 | JAMB data is stored in a JAMBDataTable. |
---|
7 | |
---|
8 | We 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 | |
---|
18 | Now 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 | |
---|
29 | We 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 | |
---|
51 | We can also get a datetime stamp, that tells, when the table was |
---|
52 | imported. This could help with maintaining old tables: |
---|
53 | |
---|
54 | >>> table.import_datetime |
---|
55 | datetime.datetime(..., ..., ..., ..., ..., ..., ...) |
---|
56 | |
---|
57 | |
---|
58 | We can delete the table: |
---|
59 | |
---|
60 | >>> del JAMBDataTable |
---|
61 | |
---|
62 | Clean up: |
---|
63 | |
---|
64 | >>> import os |
---|
65 | >>> os.unlink(datafile) |
---|