def read_header(self):
start_idx = self.file_obj.tell()<EOL>key, val = '<STR_LIT>', '<STR_LIT>'<EOL>header_dict = {}<EOL>keep_reading = True<EOL>first_line = self.file_obj<EOL>try:<EOL><INDENT>while keep_reading:<EOL><INDENT>if start_idx + <NUM_LIT> > self.filesize:<EOL><INDENT>keep_reading = False<EOL>raise EndOfFileError("<STR_LIT>")<EOL><DEDENT>line = self.file_obj.read(<NUM_LIT>)<EOL>if PYTHON3:<EOL><INDENT>line = line.decode("<STR_LIT:utf-8>")<EOL><DEDENT>if line.startswith('<STR_LIT>'):<EOL><INDENT>keep_reading = False<EOL>break<EOL><DEDENT>else:<EOL><INDENT>key, val = line.split('<STR_LIT:=>')<EOL>key, val = key.strip(), val.strip()<EOL>if "<STR_LIT:'>" in val:<EOL><INDENT>val = str(val.strip("<STR_LIT:'>").strip())<EOL><DEDENT>elif "<STR_LIT:.>" in val:<EOL><INDENT>val = float(val)<EOL><DEDENT>else:<EOL><INDENT>val = int(val)<EOL><DEDENT><DEDENT>header_dict[key] = val<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>print("<STR_LIT>", line)<EOL>print("<STR_LIT>", start_idx)<EOL>print("<STR_LIT>", self.filesize)<EOL>print("<STR_LIT>")<EOL>print(self.file_obj.read(<NUM_LIT>))<EOL>raise<EOL><DEDENT>data_idx = self.file_obj.tell()<EOL>if "<STR_LIT>" in header_dict.keys():<EOL><INDENT>if int(header_dict["<STR_LIT>"]) == <NUM_LIT:1>:<EOL><INDENT>if data_idx % <NUM_LIT>:<EOL><INDENT>data_idx += (<NUM_LIT> - data_idx % <NUM_LIT>)<EOL><DEDENT><DEDENT><DEDENT>self.file_obj.seek(start_idx)<EOL>return header_dict, data_idx<EOL>
Read next header (multiple headers in file)

        Returns:
            (header, data_idx) - a dictionary of keyword:value header data and
            also the byte index of where the corresponding data block resides.