def _read(self, filename, field_labels=None):
<EOL>def read_field(f):<EOL><INDENT>"""<STR_LIT>"""<EOL>datatype = None<EOL>while datatype is None:<EOL><INDENT>line = f.readline()<EOL>if line == "<STR_LIT>":<EOL><INDENT>return False<EOL><DEDENT>label = line[:<NUM_LIT>].strip()<EOL>if field_labels is not None:<EOL><INDENT>if len(field_labels) == <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>elif label not in field_labels:<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>field_labels.discard(label)<EOL><DEDENT><DEDENT>line = line[<NUM_LIT>:]<EOL>words = line.split()<EOL>if len(words) == <NUM_LIT:0>:<EOL><INDENT>return True<EOL><DEDENT>if words[<NUM_LIT:0>] == '<STR_LIT:I>':<EOL><INDENT>datatype = int<EOL>unreadable = <NUM_LIT:0><EOL><DEDENT>elif words[<NUM_LIT:0>] == '<STR_LIT:R>':<EOL><INDENT>datatype = float<EOL>unreadable = np.nan<EOL><DEDENT><DEDENT>if len(words) == <NUM_LIT:2>:<EOL><INDENT>try:<EOL><INDENT>value = datatype(words[<NUM_LIT:1>])<EOL><DEDENT>except ValueError:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif len(words) == <NUM_LIT:3>:<EOL><INDENT>if words[<NUM_LIT:1>] != "<STR_LIT>":<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (filename, line[:-<NUM_LIT:1>]))<EOL><DEDENT>length = int(words[<NUM_LIT:2>])<EOL>value = np.zeros(length, datatype)<EOL>counter = <NUM_LIT:0><EOL>try:<EOL><INDENT>while counter < length:<EOL><INDENT>line = f.readline()<EOL>if line == "<STR_LIT>":<EOL><INDENT>raise FileFormatError("<STR_LIT>" % filename)<EOL><DEDENT>for word in line.split():<EOL><INDENT>try:<EOL><INDENT>value[counter] = datatype(word)<EOL><DEDENT>except (ValueError, OverflowError) as e:<EOL><INDENT>print('<STR_LIT>' % (word, self.filename))<EOL>if self.ignore_errors:<EOL><INDENT>value[counter] = unreadable<EOL><DEDENT>else:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>counter += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>except ValueError:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (filename, line[:-<NUM_LIT:1>]))<EOL><DEDENT>self.fields[label] = value<EOL>return True<EOL><DEDENT>self.fields = {}<EOL>with open(filename, '<STR_LIT:r>') as f:<EOL><INDENT>self.title = f.readline()[:-<NUM_LIT:1>].strip()<EOL>words = f.readline().split()<EOL>if len(words) == <NUM_LIT:3>:<EOL><INDENT>self.command, self.lot, self.basis = words<EOL><DEDENT>elif len(words) == <NUM_LIT:2>:<EOL><INDENT>self.command, self.lot = words<EOL><DEDENT>else:<EOL><INDENT>raise FileFormatError('<STR_LIT>')<EOL><DEDENT>while read_field(f):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>
Read all the requested fields

           Arguments:
            | ``filename``  --  the filename of the FCHK file
            | ``field_labels``  --  when given, only these fields are read