导入多个文件各位,
我的问题可能以前已经提出过,因为它非常基本,但我找不到我的确切问题的解决方案。
我想导入具有相同结构的多个文件,以相同的方式操作它们,然后将它们的子集粘合在一起。 我通过以下通用方式完成了导入和数据操作部分:
dt = Open(
"PATH/File1.xlsx",
Worksheets( "Table1" ),
XXX
);
// New operation e.g. New column: Column 2
dt << New Column( "Column 2",
Numeric,
"Continuous",
Format( "Best", 12 )
);<BR /><BR />File1 = dt;<BR />File1 << Set Name("File1");<BR />为了导入更多文件,我会将相同的代码复制到脚本中,并且仅通过“File2”、“File3”等交换“File1”。 它有效,但脚本长度变得相当大,因为我有很多文件要导入。
我也尝试过国际货币基金组织的选择。 当我选择“打开多个表”(我不希望它堆叠)时,我的数据表已经链接到特定名称,并且无法使用上述通用代码来操作它们。
对于更优雅的解决方案有什么想法吗?
多谢!
数据存取数据混合和清理回复:导入多个文件使用大括号来创建特定于区域设置的字符的国际键盘可能存在问题?
https://stackoverflow.com/questions/2388805/brackets-and-international-keyboards
https://superuser.com/questions/1486481/when-i-press-the-curly-braces-key-on-the-keyboard-i-get-a-backtick-instead
https://www.reddit.com/r/Anki/comments/j1c5o2/curly_braces_dont_work_with_norwegian_keyboard/
https://cs50.stackexchange.com/questions/9603/curly-brackets-on-my-keyboard
https://discussions.apple.com/thread/7418604
回复:导入多个文件我很快想到的唯一一件事是您在函数参数周围缺少 {}
Names Default To Here(1);
open_and_modify = function(file_path, {Default Local},
dt = Open(file_path, Worksheets("Table1"), XXX);
// New operation e.g. New column: Column 2
dt << New Column("Column 2", Numeric, "Continuous", Format("Best", 12));
dt << Set Name("File1");
return(dt);
);
当它应该是
Names Default To Here(1);
open_and_modify = function({file_path}, {Default Local},
dt = Open(file_path, Worksheets("Table1"), XXX);
// New operation e.g. New column: Column 2
dt << New Column("Column 2", Numeric, "Continuous", Format("Best", 12));
dt << Set Name("File1");
return(dt);
);
回复:导入多个文件感谢你及时的答复。 我尝试实现代码,但总是收到错误消息:
“参数应在‘函数’的访问或评估中列出”,参考第 3 行
open_and_modify = function({file_path}, {Default Local},你能告诉我我犯了什么错误吗? 我总是遇到这个问题。
再次感谢!
回复:导入多个文件你可以尝试使用function() (jmp.com)或 expr()。 以下是使用 function() 的一些选项:
Names Default To Here(1);
open_and_modify = function({file_path}, {Default Local},
dt = Open(file_path, Worksheets("Table1"), XXX);
// New operation e.g. New column: Column 2
dt << New Column("Column 2", Numeric, "Continuous", Format("Best", 12));
dt << Set Name("File1");
return(dt);
);
dt1 = open_and_modify("PATH/File1.xlsx");
dt2 = open_and_modify("PATH/File2.xlsx");
dt3 = open_and_modify("PATH/File3.xlsx");
//or have a list of paths
file_paths = {"PATH/File1.xlsx", "PATH/File2.xlsx", "PATH/File3.xlsx"};
//create first concatenate before
table_list = {};
For Each({new_file_path}, files,
Insert Into(table_list, open_and_modify(new_file_path));
);