楼主: Trevor
1063 1

[问答] Merging numerous files via macro [推广有奖]

  • 1关注
  • 4粉丝

已卖:1100份资源

副教授

26%

还不是VIP/贵宾

-

TA的文库  其他...

Probability NewOccidental

RapidMiner NewOccidental

Machine Learning

威望
1
论坛币
3509 个
通用积分
0.7297
学术水平
25 点
热心指数
17 点
信用等级
24 点
经验
5225 点
帖子
412
精华
2
在线时间
176 小时
注册时间
2005-5-4
最后登录
2024-4-7

楼主
Trevor 发表于 2014-4-1 03:29:11 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

I am processing lots of files with student assessment data.  For one project I have to merge cases from ~120 different files.


Each file is for a different grade, language of test, and administration (e.g., Math3Eng1_2011, Math3Sp1_2011, Math4Eng1_2011, Math5-1_2011, Math6_2011).  Each school year there are 26-34 different files.  I want to be able to easily/efficiently merge the cases from all files for a particular school year.  To make matters more complicated, the file naming structure changes year to year.  I don’t want to merge files one at a time because a total of over 5M records exist and it takes forever to do 25+ data passes.  I don’t know how to merge multiple files in one data pass unless I hard coded the # of files to merge (but this varies).  

I could take a directory listing via windows command prompt, then using an editor add the prefixes and suffixes to each line so it can be pasted into a merge statement, but I wanted a more automated process.  

Anybody have a good suggestions?


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Files Ergin Macro file acr files

沙发
ReneeBK 发表于 2014-4-1 03:33:35
Install the Python Essentials from the SPSS Community site  ww.ibm.com/developerworks/spssdevcentral) if you haven't already done that;
Change the filespec line ;
Then run this from a syntax window.  

begin program.
import spss, glob

filespec = r"c:/temp/parts/e*.sav"

files = glob.glob(filespec)
cmd = "ADD FILES "
all = " ".join(["""/FILE="%s" """ % f for f in files])
cmd = cmd + all
spss.Submit(cmd)
end program.

dataset name merged.
exec.

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-27 04:29