如何將多個pdf文件導入數據表警告:我是腳本編寫新手
挑戰:
- 我有大約 500 個 pdf 文件,每個文件都包含一個我想要導入到 JMP 並整理成單個 jmp 數據表的數據表。
工作流程及問題:
- 我製作了一個腳本(見下文),它允許我從一個 pdf 導入表格數據並將其附加到我稱為的表格中最終.jmp 。 我將腳本保存為單獨的文件,即不在數據表中。 每個pdf都附有最終.jmp作為單行。
- 每次導入後,我必須關閉最終.jmp表並用新的、更新的“最終”表覆蓋它,該表包含新導入的 pdf 中的額外行。
- 每次導入後,我還必須手動關閉在此過程中創建的所有中間表。 (無聊的)
- 然後我在腳本中更改 pdf 文件名,按“保存”並重新運行它以導入另一個 pdf。 如此循環下去。
- 這個過程比手動複製粘貼要快,但仍然很費力,而且幾乎可以肯定沒有達到計算機科學典型的自動化程度。
問題:
- 是否可以重複運行一個腳本,每次選擇一個新的 pdf 進行導入並將其附加到同一個表中,直到一個文件夾中的所有 pdf 都已導入?
Open(
"C:\example folder\example.pdf",
PDF Tables(
Table(
table name( "1" ),
add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
add rows(
page( 1 ),
Rect( 0.9853, 4.1436, 3.0029, 4.2686 ),
column borders( 0.9853, 2.5416, 3.0029 )
),
add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
add rows(
page( 1 ),
Rect( 0.8883, 4.4136, 4.6374, 4.5386 ),
column borders( 0.8883, 1.9603, 4.6374 )
),
add rows(
page( 1 ),
Rect( 6.0143, 4.6569, 7.2498, 4.7819 ),
column borders( 6.0143, 6.5817, 7.2498 )
),
add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
)
)
);
Data Table( "1" ) << Stack(
columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Output table("2")
);
Data Table( "2" ) << Transpose(
columns( :Data ),
Output Table( "3" )
);
Data Table( "Final" ) << Concatenate( Data Table( "3" ) )
數據存取回复:如何將多個pdf文件導入數據表我的錯誤......
Data table( "Final" );
應該已指定
New Table( "Final" );
回复:如何將多個pdf文件導入數據表抱歉,我必須帶著更多問題回來,因為儘管經過多年的學術訓練,我還是無法讓這個循環發揮作用。 這是我嘗試使其工作的方法:首先,我將所有文件移動到本地硬盤,因為出於某種原因,我們在服務器上的一些文件夾名稱中使用“()”,我的印像是這會產生問題。 最終,我使用引號“引用”了腳本中的整個目錄,這似乎說服了腳本運行直到出現下一個錯誤消息。 然後它告訴我一些關於“路徑無效......'膠水'......”的信息。 我用谷歌搜索了它,但不知道如何解決這個問題。 我可以看到錯誤消息中的文件名是我要使用的目錄中的文件之一的名稱。 首先,我認為文件名中的連字符造成了問題,但即使更改也會發生錯誤。
我已經粘貼在下面:
- 帶有假目錄名的腳本副本。 我保留了文件夾的數量以及包含括號的文件夾名稱。
- 腳本窗口中的錯誤消息
- 調試時的錯誤信息
另外,如何在最終數據表中包含目錄和文件名?
預先非常感謝您! (如果你覺得這個問題太瑣碎而無法回答,我會理解的。)


Names default to here(1);
// Here is an example where the first thing that is done, is to create
// the list of the files to be processed
// Many different methods can be used to do this, but for this example
// the file names are read in from a directory
theFilesList = Files in directory( "C:\directory1\subdirectory1\subdirectory2\subdirectory3 (nameof aperson)\subdirectory4\subdirectory5\subdirectory6\subdirectory7\subdirectory8\subdirectory9\subdirectory10" );
// Create the Final data table that will have all of the processed files
// concatenated to it
Data Table( "Final" );
// Loop across all of the files and read them in one at a time and add them
// to the Final data table
For( i = 1, i <= N Items( theFilesList ), i++,
Open(
theFilesList[i],
PDF Tables(
Table(
table name( "1" ),
add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
add rows( page( 1 ), Rect( 0.9853, 4.1436, 3.0029, 4.2686 ), column borders( 0.9853, 2.5416, 3.0029 ) ),
add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
add rows( page( 1 ), Rect( 0.8883, 4.4136, 4.6374, 4.5386 ), column borders( 0.8883, 1.9603, 4.6374 ) ),
add rows( page( 1 ), Rect( 6.0143, 4.6569, 7.2498, 4.7819 ), column borders( 6.0143, 6.5817, 7.2498 ) ),
add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
)
)
);
Data Table( "1" ) << Stack(
columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Output table( "2" )
);
Data Table( "2" ) << Transpose( columns( :Data ), Output Table( "3" ) );
// Concatenate the processed data to the Final data table
Data Table( "Final" ) << Concatenate( Data Table( "3" ), Append to first table( 1 ) );
// Cleanup the environment
Close( Data Table( "1" ), nosave );
Close( Data Table( "2" ), nosave );
Close( Data Table( "3" ), nosave );
);
回复:如何將多個pdf文件導入數據表@tx尼爾森,我不知道如何充分錶達我的感激之情。 你非常非常善良。 再次非常感謝您的幫助!
回复:如何將多個pdf文件導入數據表所要做的就是循環代碼,一個接一個地讀取文件並將其添加到最終數據表中。下面的 JSL 應該為您提供如何執行此操作的良好開端。
Names default to here(1);
// Here is an example where the first thing that is done, is to create
// the list of the files to be processed
// Many different methods can be used to do this, but for this example
// the file names are read in from a directory
theFilesList = Files in directory( <PATH to="" your="" folder="" that="" has="" the="" .pdf="" files=""> );
// Create the Final data table that will have all of the processed files
// concatenated to it
Data Table( "Final" );
// Loop across all of the files and read them in one at a time and add them
// to the Final data table
For( i = 1, i <= N Items( theFilesList ), i++,
Open(
theFilesList[i],
PDF Tables(
Table(
table name( "1" ),
add rows( page( 1 ), Rect( 2.0419, 0.9776, 3.1993, 1.1726 ) ),
add rows( page( 1 ), Rect( 1.2137, 3.7819, 6.3603, 3.9069 ) ),
add rows( page( 1 ), Rect( 0.8717, 3.9636, 3.0796, 4.0886 ) ),
add rows( page( 1 ), Rect( 0.9853, 4.1436, 3.0029, 4.2686 ), column borders( 0.9853, 2.5416, 3.0029 ) ),
add rows( page( 1 ), Rect( 4.581, 4.1436, 7.297, 4.2686 ) ),
add rows( page( 1 ), Rect( 0.8883, 4.4136, 4.6374, 4.5386 ), column borders( 0.8883, 1.9603, 4.6374 ) ),
add rows( page( 1 ), Rect( 6.0143, 4.6569, 7.2498, 4.7819 ), column borders( 6.0143, 6.5817, 7.2498 ) ),
add rows( page( 1 ), Rect( 0.7556, 4.7979, 7.5908, 8.2654 ) )
)
)
);
Data Table( "1" ) << Stack(
columns( :Column 3, :Column 4, :Column 5, :Column 6 ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Output table( "2" )
);
Data Table( "2" ) << Transpose( columns( :Data ), Output Table( "3" ) );
// Concatenate the processed data to the Final data table
Data Table( "Final" ) << Concatenate( Data Table( "3" ), Append to first table( 1 ) );
// Cleanup the environment
Close( Data Table( "1" ), nosave );
Close( Data Table( "2" ), nosave );
Close( Data Table( "3" ), nosave );
);</PATH>