如何將多個pdf文件導入數據表警告:我是腳本新手
挑戰:
- 我大約有500個pdf文件,每個文件都包含一個數據表,我想將其導入JMP並整理到一個jmp數據表中。
工作流程和問題:
- 我製作了一個腳本(請參閱下文),該腳本允許我從一個pdf導入列表數據並將其附加到我稱為的表中Final.jmp 。 我將腳本保存為單獨的文件,即不在數據表中。 每個pdf都附加到Final.jmp作為單行。
- 每次導入後,我必須關閉Final.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文件導入數據表所有要做的就是循環遍歷代碼,一個接一個地讀取文件,並將其添加到Final數據表中。下面的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>回复:如何將多個pdf文件導入數據表@txnelson ,我不知道該如何表達我的感激之情。 你非常非常友善。 再次非常感謝您的幫助!
回复:如何將多個pdf文件導入數據表抱歉,我不得不回答更多問題,因為儘管經過多年的學術培訓,我仍然無法使這個循環發揮作用。 這是我要使其正常工作的方法:首先,我將所有文件都移到了本地硬盤上,因為由於某些原因,我們在服務器上的某些文件夾名稱中使用了“()”,並且給人的印像是這在造成問題。 最終,我用引號“引用”了腳本中的整個目錄,這似乎說服了腳本運行,直到出現下一條錯誤消息為止。 然後它告訴我一些有關“路徑無效...'膠水'...”的信息。 我用谷歌搜索,但不知道如何解決該問題。 我可以看到錯誤消息中的文件名是我要使用的目錄中文件之一的名稱。 首先,我認為文件名中的連字符引起了問題,但是即使更改該錯誤也會發生。
我粘貼在下面:
- 具有偽目錄名稱的腳本副本。 我保留了文件夾的數量以及包含括號的文件夾名稱。
- 腳本窗口中的錯誤消息
- 調試錯誤消息
另外,如何在最終數據表中包含目錄AND文件名?
提前非常感謝您! (如果您覺得這太瑣碎而無法回答,我會理解的。)


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文件導入數據表我的錯誤.....
Data table( "Final" );
應該已經指定
New Table( "Final" );