Welcome, guest | Sign In | My Account | Store | Cart

Return list with opened datasets

Python, 12 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def GetListOfDatasets(): #this is because the spss fuctnion getDatasets did not work
    """Return list with opened datasets.
    """
    
    cmd = """DATASET DISPLAY."""
    handle,failcode=spssaux.CreateXMLOutput(cmd,'Dataset Display','Datasets',False)
    if failcode<>0:
        return None #something went wrong
    listDS = spssaux.GetValuesFromXMLWorkspace(tag=handle,tableSubtype='Datasets',hasCols=False)
    
    spss.DeleteXPathHandle(handle)
    return listDS

I tried spss.GetDatasets() but was not able to get it running. It was always returning None (even I used it within the block "with spss.DataStep()")

So I created simple replacement to the given function which someone may find useful too.

Created by Petr Zizka on Thu, 27 Oct 2011 (MIT)
Python recipes (4591)
Petr Zizka's recipes (2)

Required Modules

Other Information and Tasks