def caseiter_to_caseset(caseiter, varnames=None, include_errors=False):

    caseset = CaseSet()

    for case in caseiter:
        if include_errors is False and case.msg:
            continue  # case reported an error, so don't use it
        if varnames is not None:
            caseset.record_case(case.subcase(varnames))
        else:
            caseset.record_case(case)
    return caseset
Retrieve the values of specified variables from cases in a CaseIterator.
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.lib/src/openmdao/lib/casehandlers/caseset.py/caseiter_to_caseset