複数のPDFファイルをデータテーブルにインポートする方法警告: 私はスクリプトの初心者です
チャレンジ:
- 約 500 個の PDF ファイルがあり、それぞれに JMP にインポートして単一の JMP データ テーブルに照合したいデータ テーブルが含まれています。
仕事の流れと課題:
- 1 つの PDF から表形式のデータをインポートし、呼び出したテーブルにそれを追加できるスクリプト (以下を参照) を作成しました。 Final.jmp 。 スクリプトを別のファイルとして、つまりデータ テーブル内に保存しませんでした。 各PDFは以下に追加されますFinal.jmp単一の行として。
- インポートするたびに、 Final.jmpテーブルを作成し、新しくインポートされた PDF からの追加行を含む新しい更新された「最終」テーブルで上書きします。
- インポートのたびに、そのプロセスで作成されているすべての中間テーブルを手動で閉じる必要もあります。 (つまらない)
- 次に、スクリプト内の PDF ファイル名を変更し、保存を押して再実行して、さらに別の PDF をインポートします。 そしてそのサイクルが続きます。
- このプロセスは手動でコピー&ペーストするよりも高速ですが、それでも手間がかかり、コンピューター サイエンスに典型的な程度まで自動化されることはほぼ確実ではありません。
質問:
- 1 つのフォルダー内のすべての 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" ) )
データアクセスRe: 複数の PDF ファイルをデータテーブルにインポートする方法私の間違い……
Data table( "Final" );
指定されるべきだった
New Table( "Final" );
Re: 複数の PDF ファイルをデータテーブルにインポートする方法申し訳ありませんが、さらに質問させていただきます。なぜなら、何年にもわたって学術的な訓練を受けてきたにもかかわらず、どういうわけかこのループを機能させることができないからです。 これを機能させるために私が試みたのは次のとおりです。 まず、すべてのファイルをローカル ハードディスクに移動しました。何らかの理由で、サーバー上のフォルダー名の一部に「()」が使用されており、これが問題を引き起こしているという印象を持ったからです。 。 最終的には、スクリプト内のディレクトリ全体を引用符を使用して「引用」しました。これにより、次のエラー メッセージが表示されるまでスクリプトが実行されるようになったようです。 それから、「パスが無効です...'Glue'...」について何か言われました。 グーグルで調べましたが、その問題に対処する方法がわかりません。 エラー メッセージ内のファイル名が、処理したいディレクトリ内のファイルの 1 つの名前であることがわかります。 最初はファイル名のハイフンが問題を引き起こしているのかと思いましたが、それを変更してもエラーが発生します。
以下に貼り付けました:
- 偽のディレクトリ名を持つスクリプトのコピー。 フォルダーの数と括弧を含むフォルダー名を保存しました。
- スクリプトウィンドウからのエラーメッセージ
- デバッグ時のエラーメッセージ
また、最終的なデータテーブルにディレクトリとファイル名を含めるにはどうすればよいですか?
事前にどうもありがとうございました! (些細すぎて答えられないと思われる場合は、ご理解いただきます。)


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 );
);
Re: 複数の PDF ファイルをデータテーブルにインポートする方法@txnelson , 感謝の気持ちをどう適切に表現したらよいのかわかりません。 あなたはとてもとても親切です。 またお世話になり、本当にありがとうございました!
Re: 複数の 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>