我正在嘗試打開一個文件夾並掃描文件,然後對不同的文件運行不同的功能。到目前為止,我已經完成了此操作,但是看起來一旦命中該功能,文件就會進入無限循環,但是如果我有1條print語句,則不會執行此操作。僅在單獨使用而不會麻煩選擇目錄和打開文件的情況下,進入無限循環的函數部分可以很好地工作。任何人都可以指出無限循環獨自起作用的原因。
myfunc = function({dt,mypath},{Dedault Local},
col_list = dt << get column names( string );
new_list = {};
For( i = N Items( col_list ), i > 0, i--, //For loop to create an array of the different column strings
If( Regex( col_list[i], "<SOME regex="">") == col_list[i],
Insert Into( new_list, col_list[i] ), //Insert Into(new_list,col_list[i]),
Remove From( col_list, i ); //If the string is not what we are looking for remove it from the array
)
);
Return(new_list);
);
mypath = Pick Directory ( "Select a directory." );
files = Files In Directory(mypath);
MY_FILES = files;
FOR(i=1, i <= N items(files), i++,
if(Ends with(files[i],"_myfile.csv"),
dt = Open(mypath || files[i]);
dname = dt << Get Name;
If(
Contains( dname, "_myfile" ) > 0, myfunc(dt,mypath),
"File is wrong"
); ,
));
</SOME>