pydicom.fileutil.find_bytes

pydicom.fileutil.find_bytes(fp, bytes_to_find, read_size=128, rewind=True)

Read in the file until a specific byte sequence found.

Parameters:
  • fp (file-like) – The file-like to search.
  • bytes_to_find (str) – 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.
Returns:

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

Return type:

int or None