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