A survey of 39 comets using CCD spectroscopy