以堆疊格式合併來自不同工作簿的數據JMP 專家您好,
我正在尋找一種選項,透過將不同 Excel 工作簿中的資料堆疊在一個標題下,將它們合併到一個 JMP 檔案中。
請建議從多個工作簿匯入資料的最佳選項[請記住,這不是工作表]
順便說一下,我在 Mac 作業系統上使用 JMP 15 pro。
提前致謝。
回覆:以堆疊格式合併來自不同工作簿的數據看起來「theFiles」清單的定義不正確或不存在。theFiles 的值是多少,變數 i 的值是多少?
回覆:以堆疊格式合併來自不同工作簿的數據我嘗試了這個腳本,並收到以下錯誤。 不知道發生了什麼,想知道您是否可以提供幫助。 謝謝。

回覆:以堆疊格式合併來自不同工作簿的數據- 我提供的腳本是基於要讀入的 JSL 工作簿清單。該列表稱為 theFiles。在我的腳本中,它是透過從給定目錄/資料夾結構讀取所有 .xlsx 檔案來創建的。但您可以更改它,然後手動建立該清單。
theFiles = {"complete path to workbook 1", "complete path to workbook 2"
"complete path to workbook 3" };「工作簿 n 的完整路徑」的一個虛構例子是:"C:\Excel Data\2020\January\Department21 Monthly.xlsx"
因此,您只需刪除第 3-11 行中的程式碼並將其替換為「theFiles」清單的新定義,腳本就會為您提供所需的結果。
- 該腳本將從其開啟的任何工作簿中讀取所有工作表,並將它們放入單一 JMP 資料表中,然後該腳本會將其新增至腳本建立的總體最終資料表中。
- 您需要提高 JMP JSL 技能,以便能夠負責腳本的使用和維護。或者,如果這不在您的工作定義範圍內,那麼您需要找到預算來僱用某人來支持代碼。使用剛剛傳遞給您的腳本是一件非常值得懷疑的事情。JMP 提供有關學習 JSL 的免費文件、範例和教學。此外,他們還提供「有償」JSL 培訓課程。JMP 社群討論參與者可以幫助解決問題,但假設他們能夠編寫您可能需要的最終腳本將是錯誤的決定。
- 以下是我的原始腳本的修改,將手動輸入要閱讀的工作簿的路徑的範例程式碼放入其中
Names Default To Here( 1 );
theFiles = {"complete path to workbook 1", "complete path to workbook 2"
"complete path to workbook 3" };
// create the base data table that all other tables will be concatenated to
dtFinal = New Table( "All Data" );
// loop through all .xlsx files and concatenate them to dtFinal
// the Concatenate Worksheets(1) will result in a single data table
// for each workbook read in and that single data table will be concatenated
// to the dtFinal
For( i = 1, i <= N Items( theFiles ), i++,
dt = Open(
theFiles[i],
Use for all sheets( 1 ),
Concatenate Worksheets( 1 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
// concatenate the new table with the dtFinal table
dtFinal << concatenate( dt, append to first table( 1 ) );
// delete the no longer needed data table dt
Close( dt, nosave );
);回覆:以堆疊格式合併來自不同工作簿的數據感謝您的快速回复,txnelson。
但老實說,我不擅長編輯 .jsl 腳本。 我不知道在上面的共用 jsl 腳本中我必須編輯哪些步驟。
現在,我有「n」不。類似類型的 Excel 工作簿位於一個資料夾中。 每個 Excel 工作簿都有多個工作表,但我的重點是將所有工作簿中名為「資料」的工作表中的資訊組合在一起。
假設這種情況,您能否進一步指導我編輯給定的腳本?
另外,如果您對「多檔案匯入」精靈有任何想法,請針對給定場景提出建議。 如果各個工作簿只有一個工作表,我可以合併多個工作簿中的資料。 但是,我不知道,對於我在這裡給出的場景,正確的步驟是什麼[即。如果每個工作簿有多個工作表。]回覆:以堆疊格式合併來自不同工作簿的數據下面的範例應該可以讓您了解如何解決此問題。您可能需要根據實際結構的詳細資訊進行更改
Names Default To Here( 1 );
// get the workbooks to be processed
theFiles = Files in Directory(<YOUR path="">, recursive(1) );
// reduce the list to only .xlsx entries
For( i = N Items( theFiles ), i >= 1, i--,
If( Word( -1, theFiles[i], "." ) != "xlsx",
Remove From( theFiles, i, 1 )
)
);
// create the base data table that all other tables will be concatenated to
dtFinal = New Table( "All Data" );
// loop through all .xlsx files and concatenate them to dtFinal
// the Concatenate Worksheets(1) will result in a single data table
// for each workbook read in and that single data table will be concatenated
// to the dtFinal
For( i = 1, i <= N Items( theFiles ), i++,
dt = Open(
theFiles[i],
Use for all sheets( 1 ),
Concatenate Worksheets( 1 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 1 ),
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 2 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
// concatenate the new table with the dtFinal table
dtFinal << concatenate( dt, append to first table( 1 ) );
// delete the no longer needed data table dt
Close( dt, nosave );
);</YOUR>