def read(filepath, limit=None, verbose=False):
  """Read jsonl file to a List of Dicts."""
  data = []
  with gfile.GFile(filepath, "r") as jsonl_file:
    for idx, line in enumerate(jsonl_file):
      if limit is not None and idx >= limit:
        break
      if verbose and idx % 100 == 0:
        # Print the index every 100 lines.
        print("Processing line %s." % idx)
      try:
        data.append(json.loads(line))
      except json.JSONDecodeError as e:
        print("Failed to parse line: `%s`" % line)
        raise e
  print("Loaded %s lines from %s." % (len(data), filepath))
  return data
Read jsonl file to a List of Dicts.
language/quest/common/jsonl_utils.py