(filepattern, max_lines=None, split_on_newlines=True)
Reads files matching a wildcard pattern, yielding the contents.

  Args:
    filepattern: A wildcard pattern matching one or more files.
    max_lines: If set, stop reading after reading this many lines.
    split_on_newlines: A boolean. If true, then split files by lines and strip
        leading and trailing whitespace from each line. Otherwise, treat each
        file as a single string.

  Yields:
    The contents of the files as lines, if split_on_newlines is True, or
    the entire contents of each file if False.
Reads files matching a wildcard pattern, yielding the contents.
Reads files matching a wildcard pattern yielding the contents .
def _read_filepattern(filepattern, max_lines=None, split_on_newlines=True):
  """Reads files matching a wildcard pattern, yielding the contents.

  Args:
    filepattern: A wildcard pattern matching one or more files.
    max_lines: If set, stop reading after reading this many lines.
    split_on_newlines: A boolean. If true, then split files by lines and strip
        leading and trailing whitespace from each line. Otherwise, treat each
        file as a single string.

  Yields:
    The contents of the files as lines, if split_on_newlines is True, or
    the entire contents of each file if False.
  """
  filenames = sorted(tf.io.gfile.glob(filepattern))
  lines_read = 0
  for filename in filenames:
    with tf.io.gfile.GFile(filename) as f:
      if split_on_newlines:
        for line in f:
          yield line.strip()
          lines_read += 1
          if max_lines and lines_read >= max_lines:
            return

      else:
        if max_lines:
          doc = []
          for line in f:
            doc.append(line)
            lines_read += 1
            if max_lines and lines_read >= max_lines:
              yield "".join(doc)
              return
          yield "".join(doc)

        else:
          yield f.read()
def _read_filepattern ( filepattern , max_lines = None , split_on_newlines = True ) : filenames = sorted ( tf . io . gfile . glob ( filepattern ) ) lines_read = 0 for filename in filenames : with tf . io . gfile . GFile ( filename ) as f : if split_on_newlines : for line in f : yield line . strip ( ) lines_read += 1 if max_lines and lines_read >= max_lines : return else : if max_lines : doc = [ ] for line in f : doc . append ( line ) lines_read += 1 if max_lines and lines_read >= max_lines : yield "" . join ( doc ) return yield "" . join ( doc ) else : yield f . read ( )