[英]copy and paste specific cells from EXCEL into specific SPSS cells
I am trying to copy data from excel into SPSS.我正在尝试将 excel 中的数据复制到 SPSS 中。 I have 80 excel files and need to copy and paste the same cells from each workbook into my main SPSS database.我有 80 个 excel 文件,需要将每个工作簿中的相同单元格复制并粘贴到我的主 SPSS 数据库中。 Is there any way I can do this aside from manually copying and pasting each individual value?除了手动复制和粘贴每个单独的值之外,我还有什么方法可以做到这一点?
Another approach if you have at least SPSS Statistics 17 would be to use the SPSSINC PROCESS FILES extension command available from the SPSS Community website (www.ibm.com/developerworks/spssdevcentral).如果您至少有 SPSS Statistics 17,另一种方法是使用 SPSS 社区网站 (www.ibm.com/developerworks/spssdevcentral) 上提供的 SPSSINC PROCESS FILES 扩展命令。 This can loop over a set of files and apply SPSS syntax to each, including GET DATA to read the files.这可以遍历一组文件并对每个文件应用 SPSS 语法,包括 GET DATA 来读取文件。 So it could read through the Excel files you want, open them in SPSS Statistics, and then select out whatever portion of the dataset is appropriate.因此它可以读取您想要的 Excel 文件,在 SPSS Statistics 中打开它们,然后 select 读取数据集的任何适当部分。
This requires the Python Essentials/plugin for your Statistics version also available from the Community website, but no skills other than with SPSS syntax are required.这需要您的 Statistics 版本的 Python Essentials/plugin 也可从社区网站获得,但除了 SPSS 语法之外不需要其他技能。
HTH, Jon Peck HTH,乔恩·派克
I use SPSS at my work, and we import data from excel on a daily basis.我在工作中使用 SPSS,我们每天从 excel 导入数据。 We do a save-as to tab delimited text format, and use a SPSS Syntax
script to import the text files.我们执行另存为制表符分隔的文本格式,并使用 SPSS Syntax
脚本导入文本文件。 Since you have so many excel files you could automate the whole "save-as" process with some vba if that would make things easier.既然你有这么多 excel 文件,你可以用一些 vba 自动化整个“另存为”过程,如果这会让事情变得更容易的话。
UPDATE更新
Here is a small bit of code to loop through (Excel) files in a directory, open each one, then save as a tab delimited text file.这是一小段代码,用于遍历目录中的(Excel)文件,打开每个文件,然后另存为制表符分隔的文本文件。 Change the .xls
designation if your files are.如果您的文件是,请更改.xls
名称。 xlsx
or .xlsm
, also you'll want to change the folder paths to something meaningful... xlsx
或.xlsm
,您还需要将文件夹路径更改为有意义的...
Sub TestMe()
Dim wb As Workbook
Dim INfldr As String
Dim OUTfldr as String
OUTfldr = "C:\WhereIPutStuff\"
INfldr = "C:\WhereIKeepStuff\"
strFNAME = Dir(INfldr & "*.xls")
i = 1
Do
Set wb = Application.Workbooks.Open(INfldr & strFNAME)
wb.SaveAs Filename:=OUTfldr & "OutputFile(" & i & ").txt", _
FileFormat:=xlText, _
CreateBackup:=False
wb.Close False
i = i + 1
strFNAME = Dir
Loop Until strFNAME = ""
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.