A client has many raw data files in excel with code books with value labels and variable labels also in excel. I want to use Python to apply the var labels and value labels using xlrd. I am using SPSS 23 in windows 10. When I run begin program. xlsPath = r'd:\test3.xls' import xlrd valLabCmd = '' wb = xlrd.open_workbook(xlsPath) valLabs = wb.sheets()[0] for rowCnt in range(valLabs.nrows): rowVals = valLabs.row_values(rowCnt) valLabCmd += "add value labels %s %d '%s'.\n"%(rowVals[0],rowVals[1],rowVals[2].replace("'","''")) print valLabCmd end program. I get Traceback (most recent call last): File "<string>", line 3, in <module> ImportError: No module named xlrd So clearly xlrd is not available,but python is running I have tried using easy install and get feedback that the xlrd was registered. But I think it is being registered in the c:\python version of python rather than the python implement in SPSS. So I deleted he c:\Python folder and used the recommendation here http://www.spss-tutorials.com/xlrd-python/ which alter the environment setting so that python should be accessible. But when I run the setup.py install . command form within the XLRD folder as recommended , I am prompted to identify and application . and that is a show stopper.I wonder if any out there have suggestions about how to move forward because at this point I am stuck. Thanks, Bill William N Dudley, PhD President Piedmont Research Strategies, Inc |
You can use a Python distribution different from the one distributed with Statistics (but the same version of Python - 2.7 in V23). The one Statistics installs is not registered as the official version on your system in order to minimize the impact of the install. This creates problems when installing additional modules. So, the distribution installed with Statistics should be present as it adds additional modules. Then, if you have another 2.7 installed, install xlrd or whatever, and it will be added to that distribution. Then just go to Edit > Options > Files in Statistics and click Other Installation under Python location and enter the location. Restart Statistics and you should be good to go. On Sat, Jul 16, 2016 at 12:53 PM, William Dudley <[hidden email]> wrote:
|
In reply to this post by William Dudley
Not sure if it’s exactly what you need, but have a look at StatTransfer From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of William Dudley A client has many raw data files in excel with code books with value labels and variable labels also in excel. I want to use Python to apply the var labels and value labels using xlrd. I am using SPSS 23 in windows 10. When I run begin program. xlsPath = r'd:\test3.xls' import xlrd valLabCmd = '' wb = xlrd.open_workbook(xlsPath) valLabs = wb.sheets()[0] for rowCnt in range(valLabs.nrows): rowVals = valLabs.row_values(rowCnt) valLabCmd += "add value labels %s %d '%s'.\n"%(rowVals[0],rowVals[1],rowVals[2].replace("'","''")) print valLabCmd end program. I get Traceback (most recent call last): File "<string>", line 3, in <module> ImportError: No module named xlrd So clearly xlrd is not available,but python is running I have tried using easy install and get feedback that the xlrd was registered. But I think it is being registered in the c:\python version of python rather than the python implement in SPSS. So I deleted he c:\Python folder and used the recommendation here http://www.spss-tutorials.com/xlrd-python/ which alter the environment setting so that python should be accessible. But when I run the I wonder if any out there have suggestions about how to move forward because at this point I am stuck. Thanks, Bill -- William N Dudley, PhD President Piedmont Research Strategies, Inc ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Did you ever get a solution to this?
I am in the same situation. -- Sent from: http://spssx-discussion.1045642.n5.nabble.com/ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
Free forum by Nabble | Edit this page |