pydicom.fileutil.find_bytes(fp: BinaryIO, bytes_to_find: bytes, read_size: int = 128, rewind: bool = True) int | None[source]

Read in the file until a specific byte sequence found.

  • fp (file-like) – The file-like to search.

  • bytes_to_find (bytes) – Contains the bytes to find. Must be in correct endian order already.

  • read_size (int) – Number of bytes to read at a time.

  • rewind (bool) – Flag to rewind file reading position.


found_at – Position where byte sequence was found, else None.

Return type:

int or None