def parse_data_line(self, sline):
        """
        Parse the data line. If an AS was selected it can distinguish between data rows and information rows.
        :param sline: a split data line to parse
        :returns: the number of rows to jump and parse the next data line or return the code error -1
        """
        # if there are less values founded than headers, it's an error
        if len(sline) != len(self._columns):
            self.err("One data line has the wrong number of items")
            return 0
        if self.analysiskey:
            # If an AS is selected it should saves all the columns from the same row under the selected AS.
            rawdict = {}
            for idx, result in enumerate(sline):
                # All data is interpreted as different fields from the same AS
                rawdict[self._columns[idx]] = result
            rid = rawdict.get('Sample ID No')
            if not rid:
                self.err("No Sample ID defined",
                         numline=self._numline)
                return -1
            rawdict['DefaultResult'] = self.defaultresult \
                                     if self.defaultresult in self._columns \
                                     else self.err("Default Result Key " + self.defaultresult + " not found")
            rawdict['DateTime'] = csvDate2BikaDate(rawdict['Analysis Date'], rawdict['Analysis Time'])
            self._addRawResult(rid, {self.analysiskey: rawdict}, False)

        else:
            # If non AS is selected it should saves all data under the same analysed sample (Sample ID No), and ignore
            # the less important rows from the line.
            headerdict = {}
            datadict = {}
            for idx, result in enumerate(sline):
                if self._columns[idx] not in self._excludedcolumns:
                    datadict[self._columns[idx]] = {'Result': result, 'DefaultData': 'Result'}
                else:
                    headerdict[self._columns[idx]] = result
            rid = headerdict['Sample ID No']
            datadict['DateTime'] = csvDate2BikaDate(headerdict['Analysis Date'], headerdict['Analysis Time'])
            self._addRawResult(rid, datadict, False)
            self._header = headerdict
            return 0
def parse_data_line ( self , sline ) : if len ( sline ) != len ( self . _columns ) : self . err ( "One data line has the wrong number of items" ) return 0 if self . analysiskey : rawdict = { } for idx , result in enumerate ( sline ) : rawdict [ self . _columns [ idx ] ] = result rid = rawdict . get ( 'Sample ID No' ) if not rid : self . err ( "No Sample ID defined" , numline = self . _numline ) return - 1 rawdict [ 'DefaultResult' ] = self . defaultresult if self . defaultresult in self . _columns else self . err ( "Default Result Key " + self . defaultresult + " not found" ) rawdict [ 'DateTime' ] = csvDate2BikaDate ( rawdict [ 'Analysis Date' ] , rawdict [ 'Analysis Time' ] ) self . _addRawResult ( rid , { self . analysiskey : rawdict } , False ) else : headerdict = { } datadict = { } for idx , result in enumerate ( sline ) : if self . _columns [ idx ] not in self . _excludedcolumns : datadict [ self . _columns [ idx ] ] = { 'Result' : result , 'DefaultData' : 'Result' } else : headerdict [ self . _columns [ idx ] ] = result rid = headerdict [ 'Sample ID No' ] datadict [ 'DateTime' ] = csvDate2BikaDate ( headerdict [ 'Analysis Date' ] , headerdict [ 'Analysis Time' ] ) self . _addRawResult ( rid , datadict , False ) self . _header = headerdict return 0
Parse the data line. If an AS was selected it can distinguish between data rows and information rows.
        :param sline: a split data line to parse
        :returns: the number of rows to jump and parse the next data line or return the code error -1