def _next_case(self):
        uuid = parent_uuid = msg = ""
        uuid_field = parent_uuid_field = msg_field = None
        if self.headers is None:
            input_fields = {}
        else:
            input_fields = self.headers
        output_fields = {}

        for row in self.data:

            # Get fieldnames from file
            if self._need_fieldnames:

                # OpenMDAO-style CSV file
                if '/INPUTS' in row:
                    input_fields, output_fields = self._parse_fieldnames(row)

                    self.timestamp_field = 1
                    uuid_field = row.index('/METADATA') + 1
                    parent_uuid_field = uuid_field + 1
                    msg_field = uuid_field + 2

                # Read headers from file
                elif self.headers is None:
                    for i, field in enumerate(row):
                        if field == 'timestamp':
                            self.timestamp_field = i
                        else:
                            input_fields[i] = field

                self._need_fieldnames = False
                continue

            if uuid_field is not None:
                uuid = row[uuid_field]
                parent_uuid = row[parent_uuid_field]
                msg = row[msg_field]

            inputs = []
            for i, field in input_fields.iteritems():

                # Convert bools from string back into bools
                # Note, only really need this for inputs.
                if row[i] in ['True', 'False']:
                    row[i] = bool(row[i])

                inputs.append((field, row[i]))

            outputs = []
            for i, field in output_fields.iteritems():
                outputs.append((field, row[i]))

            exc = None if not msg else Exception(msg)

            yield Case(inputs=inputs, outputs=outputs, exc=exc,
                       parent_uuid=parent_uuid)

        self._need_fieldnames = True
Generator which returns Cases one at a time.
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/casehandlers/csvcase.py/CSVCaseIterator._next_case