def __len__(self):
        """Provide a len attribute based on max_docs and number of rows in files."""
        cnt_docs = 0
        for fp in self.all_files:
            with codecs.open(fp, encoding=self.encoding) as tsv:
                num_lines = sum(1 for line in tsv)
                cnt_docs += num_lines - 1 if self.header else num_lines
            if cnt_docs > self.max_docs:
                break
        num_docs = min(cnt_docs, self.max_docs)
        return num_docs
def __len__ ( self ) : cnt_docs = 0 for fp in self . all_files : with codecs . open ( fp , encoding = self . encoding ) as tsv : num_lines = sum ( 1 for line in tsv ) cnt_docs += num_lines - 1 if self . header else num_lines if cnt_docs > self . max_docs : break num_docs = min ( cnt_docs , self . max_docs ) return num_docs
Provide a len attribute based on max_docs and number of rows in files.