Reads the Comtrade header file (.cfg).

def ReadCFG(self):
        """
        Reads the Comtrade header file (.cfg).
        """
            
        self.filehandler = open(self.filename,'r')
        # Processing first line:
        line = self.filehandler.readline()
        templist = line.split(',')
        self.station_name = templist[0]
        self.rec_dev_id = templist[1]
        # Odd cfg file may not contain all first line fields
        # checking vector length to avoid IndexError
        if len(templist) > 2:
            self.rev_year = int(templist[2])

        # Processing second line:
        line = self.filehandler.readline().rstrip() # Read line and remove spaces and new line characters.
        templist = line.split(',')
        self.TT = int(templist[0])
        self.A = int(templist[1].strip('A'))
        self.D = int(templist[2].strip('D'))

        # Processing analog channel lines:
        for i in range(self.A): #@UnusedVariable
            line = self.filehandler.readline()
            templist = line.split(',')
            self.An.append(int(templist[0]))
            self.Ach_id.append(templist[1])
            self.Aph.append(templist[2])
            self.Accbm.append(templist[3])
            self.uu.append(templist[4])
            self.a.append(float(templist[5]))
            self.b.append(float(templist[6]))
            self.skew.append(float(templist[7]))
            self.min.append(int(templist[8]))
            self.max.append(int(templist[9]))
            # Odd cfg file may not contain all analog channel fields
            # checking vector length to avoid IndexError
            if len(templist) > 10:
                self.primary.append(float(templist[10]))
            if len(templist) > 11:
                self.secondary.append(float(templist[11]))
            if len(templist) > 12:
                self.PS.append(templist[12])

        # Processing digital channel lines:
        for i in range(self.D): #@UnusedVariable
            line = self.filehandler.readline()
            templist = line.split(',')
            self.Dn.append(int(templist[0]))
            self.Dch_id.append(templist[1])
            self.Dph.append(templist[2])
            # Odd cfg file may not contain all digital channel fields
            # checking vector length to avoid IndexError
            if len(templist) > 3:
                self.Dccbm.append(templist[3])
            if len(templist) > 4:
                self.y.append(int(templist[4]))

        # Read line frequency:
        self.lf = int(float(self.filehandler.readline()))

        # Read sampling rates:
        self.nrates = int(self.filehandler.readline()) # nrates.
        for i in range(self.nrates): #@UnusedVariable
            line = self.filehandler.readline()
            templist = line.split(',')
            self.samp.append(int(float(templist[0])))
            self.endsamp.append(int(float(templist[1])))

        # Read start date and time ([dd,mm,yyyy,hh,mm,ss.ssssss]):
        line = self.filehandler.readline()
        templist = line.split('/')
        self.start[0] = int(templist[0]) # day.
        self.start[1] = int(templist[1]) # month.
        templist = templist[2].split(',')
        self.start[2] = int(templist[0]) # year.
        templist = templist[1].split(':')
        self.start[3] = int(templist[0]) # hours.
        self.start[4] = int(templist[1]) # minutes.
        self.start[5] = float(templist[2]) # seconds.

        # Read trigger date and time ([dd,mm,yyyy,hh,mm,ss.ssssss]):
        line = self.filehandler.readline()
        templist = line.split('/')
        self.trigger[0] = int(templist[0]) # day.
        self.trigger[1] = int(templist[1]) # month.
        templist = templist[2].split(',')
        self.trigger[2] = int(templist[0]) # year.
        templist = templist[1].split(':')
        self.trigger[3] = int(templist[0]) # hours.
        self.trigger[4] = int(templist[1]) # minutes.
        self.trigger[5] = float(templist[2]) # seconds.

        # Read file type:
        self.ft = self.filehandler.readline()
        
        # Read time multiplication factor:
        # Odd cfg file may not have multiplication field, so checking
        # its existance before reading is a safe measure
        # If the multiplication field is not available, it will be considered as 1
        self.timemul = self.filehandler.readline()
        if self.timemul != '':
            self.timemul = float(self.timemul)
        else:
            self.timemul = 1

        # END READING .CFG FILE.
        self.filehandler.close()