def loadSavFile(self, savFileName, interfaceEncoding):
        """ This function loads the spss I/O file (.dll or .so file) and opens
        the spss data file for reading."""
        platform = sys.platform.lower()
        if platform.startswith("win"):
            try:
                os.environ["PATH"] += ";" + os.path.abspath(".")
                spssio = ctypes.windll.spssio32
                self.libc = ctypes.cdll.msvcrt
                fopen = self.libc._fdopen # libc.fopen() won't work on windows
            except WindowsError, e:
                msg = "Cannot find spssio32.dll in '%s'.\n" % os.path.abspath(".") + \
                      "Py file and Dll should live in the same directory [%s]." % e
                raise Exception, msg
        elif platform.startswith("linux"):
            # add library search path to LD_LIBRARY_PATH environment variable
            # Type this in the terminal **before** running the program:
            # LD_LIBRARY_PATH=/path/of/additional/sofiles
            # export LD_LIBRARY_PATH
            # also need libirc.so from intel-icc8-libs_8.0-1_i386 (?) but this is broken.
            # or perhaps intel-icc9-libs-9.0-025.i386 (?)
            path = os.path.abspath(".")
            os.environ["PATH"] += ":" + path
            libicuuc = ctypes.CDLL("libicuuc.so.32.0")
            libicudata = ctypes.CDLL("libicudata.so.32")
            libicu32 = ctypes.CDLL("libicu.so.32.0") # ??
            spssio = ctypes.CDLL("%s/libspssdio.so.1" % path)
            self.libc = ctypes.CDLL("libc.so.6")
            fopen = self.libc.fopen
        else:
            msg = "Your platform ('%s') is not supported" % platform
            raise NotImplementedError, msg

        self.setInterfaceEncoding(spssio, interfaceEncoding)
        
        if os.path.exists(self.savFileName):
            fh = fopen(self.savFileName, "rb")
            fhPtr = ctypes.byref(ctypes.c_int(fh))
            retcode = spssio.spssOpenRead(ctypes.c_char_p(self.savFileName), fhPtr)
            return retcode, spssio, fh
        else:
            raise Exception, "File '%s' does not exist!" % self.savFileName
 This function loads the spss I/O file (.dll or .so file) and opens
        the spss data file for reading.
recipes/Python/577650_Python_reader_for_spss_sav_files/recipe-577650.py