導入多個文件各位,
我的問題可能以前已經提出過,因為它非常基本,但我找不到我的確切問題的解決方案。
我想導入具有相同結構的多個文件,以相同的方式操作它們,然後將它們的子集粘合在一起。 我透過以下通用方式完成了導入和資料操作部分:
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));
);