<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def counts(self, catalogue, output_fh):
 """Returns `output_fh` populated with CSV results giving n-gram counts of the witnesses of the works in `catalogue`. :param catalogue: catalogue matching filenames to labels :type catalogue: `Catalogue` :param output_fh: object to output results to :type output_fh: file-like object :rtype: file-like object """

        labels = list(self._set_labels(catalogue))
        label_placeholders = self._get_placeholders(labels)
        query = constants.SELECT_COUNTS_SQL.format(label_placeholders)
        self._logger.info('Running counts query')
        self._logger.debug('Query: {}\nLabels: {}'.format(query, labels))
        cursor = self._conn.execute(query, labels)
        return self._csv(cursor, constants.COUNTS_FIELDNAMES, output_fh)