def load(self, filename, subset=None):
with open(filename, "<STR_LIT:r>") as f:<EOL><INDENT>name = None<EOL>num_names = <NUM_LIT:0><EOL>while True:<EOL><INDENT>line = f.readline()<EOL>if len(line) == <NUM_LIT:0>:<EOL><INDENT>break<EOL><DEDENT>words = line.split()<EOL>name = words[<NUM_LIT:0>]<EOL>attr = self._fields.get(name)<EOL>if attr is None:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % name)<EOL><DEDENT>if not words[<NUM_LIT:1>].startswith("<STR_LIT>"):<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>kind = words[<NUM_LIT:1>][<NUM_LIT:5>:]<EOL>expected_kind = attr.get_kind(attr.get())<EOL>if kind != expected_kind:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (name, kind, expected_kind))<EOL><DEDENT>skip = ((subset is not None) and (name not in subset))<EOL>print(words)<EOL>if (words[<NUM_LIT:2>].startswith("<STR_LIT>") and words[<NUM_LIT:2>].endswith("<STR_LIT:)>")):<EOL><INDENT>if not isinstance(attr, ArrayAttr):<EOL><INDENT>raise FileFormatError("<STR_LIT>" % name)<EOL><DEDENT>shape = words[<NUM_LIT:2>][<NUM_LIT:7>:-<NUM_LIT:1>]<EOL>if shape[-<NUM_LIT:1>] == '<STR_LIT:U+002CU+0020>':<EOL><INDENT>shape = shape[:-<NUM_LIT:1>]<EOL><DEDENT>try:<EOL><INDENT>shape = tuple(int(word) for word in shape.split("<STR_LIT:U+002C>"))<EOL><DEDENT>except ValueError:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>expected_shape = attr.get().shape<EOL>if shape != expected_shape:<EOL><INDENT>raise FileFormatError("<STR_LIT>" % (name, shape, expected_shape))<EOL><DEDENT>attr.load(f, skip)<EOL><DEDENT>elif words[<NUM_LIT:2>].startswith("<STR_LIT>"):<EOL><INDENT>if not isinstance(attr, ScalarAttr):<EOL><INDENT>raise FileFormatError("<STR_LIT>" % name)<EOL><DEDENT>if not skip:<EOL><INDENT>if kind == '<STR_LIT:i>':<EOL><INDENT>attr.set(int(words[<NUM_LIT:2>][<NUM_LIT:6>:]))<EOL><DEDENT>else:<EOL><INDENT>attr.set(float(words[<NUM_LIT:2>][<NUM_LIT:6>:]))<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT>num_names += <NUM_LIT:1><EOL><DEDENT>if num_names != len(self._fields) and subset is None:<EOL><INDENT>raise FileFormatError("<STR_LIT>")<EOL><DEDENT><DEDENT>
Load data into the registered fields

           Argument:
            | ``filename``  --  the filename to read from

           Optional argument:
            | ``subset``  --  a list of field names that are read from the file.
                              If not given, all data is read from the file.