nar dat pil hou t_pe rs_ rce on_ nt_ typ pil hou t_to tal rs mid string string string string uint float int bool ive typ rat ft_ cra por uint air air cra ft_ id string air file handling rep ort _id utf- encoded bytes figure the structure of binary aircraft incident record def import_binary(selffilename)def unpack_string(fheof_is_error=true)uint struct struct("< "length_data fh read(uint sizeif not length_dataif eof_is_errorraise valueerror("missing or corrupt string size"return none length uint unpack(length_data)[ if length = return "data fh read(lengthif not data or len(data!lengthraise valueerror("missing or corrupt string"format "<{ }sformat(lengthreturn struct unpack(formatdata)[ decode("utf "since each incident record begins with its report id stringwhen we attempt to read this string and we succeedwe are at the start of new record but if we failwe've reached the end of the file and can finish we set the eof_is_error flag to false when attempting to read report id since if there is no datait just means we have finished for all other strings we accept the default of true because if any other string has no datait is an error (even an empty string will be preceded by -bit unsigned integer length we begin by attempting to read the string' length if this fails we return none to signify end of file (if we are attempting to read new incident)or we raise valueerror exception to indicate corrupt or missing data the struct unpack(function and the struct struct unpack(method always return tupleeven if it contains only single value we unpack the length data and store the number it represents in the length variable now we know how many bytes we