def check_data_indexes(self, _filename, disp): """ method used by client code explicitly, because of dynamic nature of placement of data columns which have to check at runtime to manage a situation when columns are specified by names and for different files they are placed in different columns """ message = None if not nvl(self.signal_label, self.annotation_label, self.time_label) == None: headers_count = nvl(self.headers_count, 1) file_headers = DataFileHeader(_filename, _separator=self.separator, number_of_lines=headers_count) #get header's lines headers = file_headers.getHeadersLines(headers_count) if self.signal_label: self.signal_index = get_index_of_string( self.signal_label, headers, _separator=self.separator) if self.annotation_label: self.annotation_index = get_index_of_string( self.annotation_label, headers, _separator=self.separator) if self.annotation_index == -1: message = ('There is no annotation index for label %s !' % (self.annotation_label)) if self.time_label: self.time_index = get_index_of_string( self.time_label, headers, _separator=self.separator) if self.time_index == -1: message = ('There is no time index for label %s !' % (self.time_label)) if self.signal_index == -1: if self.time_label: message = ('There is no signal index for label %s !' % (self.signal_label)) else: message = 'The signal index has to be set !' if is_positive(self.time_index) and self.time_format == None: message = 'For time column a time format parameter is required !' if not is_positive(self.time_index) and not is_empty(self.time_format): message = 'Time format requires time index column selection !' if message and disp: print('File: %s \n %s \n' % (_filename, message)) return False else: return True
def check_data_indexes(self, _filename, disp): """ method used by client code explicitly, because of dynamic nature of placement of data columns which have to check at runtime to manage a situation when columns are specified by names and for different files they are placed in different columns """ message = None if not nvl(self.signal_label, self.annotation_label, self.time_label) == None: headers_count = nvl(self.headers_count, 1) file_headers = DataFileHeader(_filename, _separator=self.separator, number_of_lines=headers_count) # get header's lines headers = file_headers.getHeadersLines(headers_count) if self.signal_label: self.signal_index = get_index_of_string(self.signal_label, headers, _separator=self.separator) if self.annotation_label: self.annotation_index = get_index_of_string(self.annotation_label, headers, _separator=self.separator) if self.annotation_index == -1: message = "There is no annotation index for label %s !" % (self.annotation_label) if self.time_label: self.time_index = get_index_of_string(self.time_label, headers, _separator=self.separator) if self.time_index == -1: message = "There is no time index for label %s !" % (self.time_label) if self.signal_index == -1: if self.time_label: message = "There is no signal index for label %s !" % (self.signal_label) else: message = "The signal index has to be set !" if is_positive(self.time_index) and self.time_format == None: message = "For time column a time format parameter is required !" if not is_positive(self.time_index) and not is_empty(self.time_format): message = "Time format requires time index column selection !" if message and disp: print("File: %s \n %s \n" % (_filename, message)) return False else: return True
def __createDataFileHeader__(self, pathFile, _separator): dataFileHeader = self.__dataFilesHeaders__.get(pathFile, None) if dataFileHeader == None: dataFileHeader = DataFileHeader(pathFile) self.__dataFilesHeaders__[pathFile] = dataFileHeader if _separator == None: _separator = dataFileHeader.getSeparator() if _separator == None: #try to discover a separator based on file data _separator = dataFileHeader.getSeparator(generate=True) dataFileHeader.setSeparator(_separator) return dataFileHeader