我正在尝试打开一个文件夹并扫描文件,然后对不同的文件运行不同的功能。到目前为止,我已经完成了此操作,但是看起来一旦命中该功能,文件就会进入无限循环,但是如果我有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>