def _read_magic(f, magic):
    """Read and compare the magic value in a data file.

    Arguments:
      f - Input file.
      magic - Magic value"

    Returns:
      True on success, False otherwise.
    """
    f_magic = f.read(len(magic))
    return f_magic == magic