如何将多个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" );