<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def writeToCSV(self, output_path=None):
        '''writeToCSV - write the telemetry dictionary to csv
        '''
        header = ['Name', 'First Byte', 'Last Byte', 'Bit Mask', 'Endian',
                  'Type', 'Description', 'Values']

        if output_path is None:
            output_path = ait.config._directory

        for pkt_name in self.tlmdict:
            filename = os.path.join(output_path, pkt_name + '.csv')

            with open(filename, 'wb') as output:
                csvwriter = csv.writer(output, quoting=csv.QUOTE_ALL)
                csvwriter.writerow(header)

                for fld in self.tlmdict[pkt_name].fields:
                    # Pre-process some fields

                    # Description
                    desc = fld.desc.replace('\n', ' ') if fld.desc is not None else ""

                    # Mask
                    mask = hex(fld.mask) if fld.mask is not None else ""

                    # Enumerations
                    enums = '\n'.join("%s: %s" % (k, fld.enum[k])
                            for k in fld.enum) if fld.enum is not None else ""

                    # Set row
                    row = [fld.name, fld.slice().start, fld.slice().stop,
                           mask, fld.type.endian, fld.type.name, desc, enums]

                    csvwriter.writerow(row)