-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
134 lines (97 loc) · 5.42 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Introduction
------------
This is a small utility intended for use in extracting a school's
historical data from SchoolBase, ready for loading into iSAMS.
It was written for one particular school and was not intended as
a general-purpose product. However, that school has given permission
for it to be released under the GPL, and it should greatly reduce
the amount of work needed to be done by other schools in the future.
It dumps some of the existing database tables in SchoolBase, then
re-structures the data as requested by iSAMS.
Because of the unfortunate choice of Excel files as the input
mechanism required by iSAMS, it is not possible fully to automate
the preparation. (Or at least, I couldn't find a way to do it, and
iSAMS were unable to make any useful suggestions. Others with more
familiarity with writing to Excel files may be able to suggest a
way.)
This utility writes CSV files which can then be manually injected
into iSAMS's Excel templates - one CSV file per sheet in a workbook.
As you do this, make sure you choose the right encoding (UTF-8) for
each CSV files. Excel will try to guess the encoding, and whilst
its guess varies, in my experience it absolutely always got it wrong.
There are two further problems with this process, around which you
will have to negotiate with iSAMS.
1) Some of the fields specified in the iSAMS template are too short.
1000 characters is not enough to hold the text of a report, and
various other things.
2) There is a bug in Excel which means it fails to handle correctly
fields containing an embedded line feed, even though the field is
correctly quoted in the CSV file. Two different approaches have
been taken to get around this.
For some of the affected text fields, this utility simply strips out
the line feed characters. The text comes across, but the formatting
into separate paragraphs is lost.
Where this was not acceptable (e.g. for academic reports) the utility
writes the fields unchanged and I did eventually find a workaround
which let me get them into Excel. Open the CSV file in LibreOffice,
being careful to specify the correct encoding (UTF-8). The CSV importer
in LibreOffice works correctly and preserves the line feeds. Then
save the new sheet in XLS or XLSX format, open it in Excel, and cut
and paste the whole sheet into your Excel workbook.
For some odd reason, Excel runs *incredibly* slowly - several minutes
to open a file - when faced with a spreadsheet which has embedded line
feeds in a file, but it does at least get there eventually.
Getting started
---------------
You will need a working copy of Ruby on your computer. This is relatively
straightforward on Linux or MacOS, and not too difficult on Windows. I would
suggest the use of RVM to get things set up quickly. The version of Ruby
used for our extraction was 2.1.10, but anything later should be fine too.
Then you need a few Gems installed. Look at code/extractor.rb for a
definitive list. The two obvious ones are:
* charlock_holmes - used because our SB d/b at least had text within
it in various encodings. The utility irons this out
and makes sure everything is in the same encoding,
UTF-8. If you want to switch to something else, this
is probably best done at the stage of writing the
final CSV files. You can specify it when opening the
files.
* tiny_tds For access to the SB database.
Create a user ID on your SB database which has only read access and edit
code/extractor.rb to use that user name. The password is entered
directly into the utility when it is run.
You also need some extra directories apart
from those created when you checked it out of git. The relevant
directories are not stored in git because they contain school-specific
confidential information.
In parallel to the code directory you need:
csv
output
yml
The csv directory is used to store the tables dumped from SchoolBase.
These are then processed to create the tables required by iSAMS, which
are written to the output directory.
The extractor works in two phases so that development work can be done
without needing immediate access to the SB database. You do:
./extractor.rb --extract
to dump the SB tables to intermediate CSV files, and then:
./extractor.rb --generate
to do all the conversion work. You can also do:
./extractor.rb --extract --generate
to do the whole thing in one go.
Type
./extractor.rb --help
to get information on other options, most of which relate to particular
little tweaks which we needed.
I would suggest setting up your database user, and then simply running
the utility and studying what comes out. It will be structurally
correct from the point of view of the iSAMS templates, but will
need adjusting to suit your particular school.
You will want to tweak the output to suit your particular requirements.
For instance, the code will do a pretty good job of taking UK addresses
from the SchoolBase address fields and breaking them up appropriately for
the iSAMS fields, but presumably you will need to handle addresses for
whatever country you're dealing with. Likewise, things like particular
rewards and sanctions which you have set up in SchoolBase will need to be
mapped to how you want them in iSAMS.
If there is an area you have decided not to transfer (e.g. medical records) you can simply ignore the corresponding output files.