Database rebuild function created

Still a bit to do with this.  At the moment, the CSVs are read and the
data is fed back into the database.  However, it reads all the data and
attempts to read it all back in even when the data is already there - so
there are a lot of error messages which could do with tidying up. But
the basic issues are sorted.