SPSSでは、Pythonプログラムを使用して、アクティブデータセットのファイル名を取得する方法はありますか?私はデータセット名については言及していません。私はファイル名が必要です。SPSS Python有効なデータセットのファイル名を取得
SPSS_Path=os.path.dirname(SpssClient.GetActiveDataDoc().GetDocumentPath())
パスを取得し、私は、ファイル名のために何か似
SPSSでは、Pythonプログラムを使用して、アクティブデータセットのファイル名を取得する方法はありますか?私はデータセット名については言及していません。私はファイル名が必要です。SPSS Python有効なデータセットのファイル名を取得
SPSS_Path=os.path.dirname(SpssClient.GetActiveDataDoc().GetDocumentPath())
パスを取得し、私は、ファイル名のために何か似
このための鍵を探していますSPSS 23でのPython Essentialsのと一緒にインストールされてspssauxモジュールは、(古いバージョンではないかもしれないましたしかし、私はそれをテストすることはできません)。 IBMフォーラムのthis old postへのクレジット
begin program.
import spss,spssaux
#this gets the whole path+filename+fileextension into a string:
Data_Info=str(spssaux.GetDatasetInfo())
#find the position of the last "/" in the above string, to determine the path
Slash_Pos=Data_Info.rfind("/")
#find the position of the last ".", to determine file extension
Ext_Pos=Data_Info.rfind(".")
#get Active File name
SPSS_Name = Data_Info[Slash_Pos+1:Ext_Pos]
#get Active File Path
SPSS_Path=Data_Info[:Slash_Pos+1]
print (SPSS_Name, SPSS_Path)
end program.
はい、この機能は長い間使用可能でした。アクティブなデータセットには必ずしもファイル名が付いていないことに注意してください。