def read_tsv(filename, expected_num_columns=2):
  """Read file to list of examples."""
  examples = []
  with gfile.GFile(filename, "r") as tsv_file:
    for line in tsv_file:
      line = line.rstrip()
      cols = line.split("\t")
      if len(cols) != expected_num_columns:
        raise ValueError("Line '%s' has %s columns (%s)" %
                         (line, len(cols), cols))
      examples.append(cols)
  print("Loaded %s examples from %s." % (len(examples), filename))
  return examples
Read file to list of examples.
language/compgen/nqg/tasks/tsv_utils.py