def read_csv(
    file_path: str, unpack_singleton_rows: bool = False
) -> Sequence[Sequence[Any]]:
  """Read a CSV file and return its contents as a list of lists.

  Create the Comma Separated Value (CSV) file if it does not already exist.

  Args:
    file_path: the path to the file to load.
    unpack_singleton_rows: if enabled, then return singleton rows without
      enclosing them in lists.

  Returns:
    The contents of the CSV file as a list of lists or a list of singletons if
      `unpack_singleton_rows` is enabled.
  """
  data = []
  with open(file_path, 'a+', encoding='utf-8') as file:
    file.seek(0)  # Move to the beginning of the file for reading
    reader = csv.reader(file, delimiter='\n')
    for row in reader:
      data.append(row)
  if unpack_singleton_rows:
    data = [row[0] for row in data if len(row) == 1]
  return data
Read a CSV file and return its contents as a list of lists.

  Create the Comma Separated Value (CSV) file if it does not already exist.

  Args:
    file_path: the path to the file to load.
    unpack_singleton_rows: if enabled, then return singleton rows without
      enclosing them in lists.

  Returns:
    The contents of the CSV file as a list of lists or a list of singletons if
      `unpack_singleton_rows` is enabled.
  
examples/deprecated/modular/utils/files.py