複数のPDFファイルをインポートする警告:私はコーディングに不慣れです!
インポートしたい表形式のデータを含む約500のPDFファイルがあります。 データを抽出、スタック、転置し、テーブルに追加/連結するスクリプトを作成することができました(これを「 final.jmp ")。 各PDFは、の1行で表されます。 final.jmp 。 これがワークフローと問題私が特定したもの:
- 複数のPDFをインポートする方法がわからなかったため、スクリプトにインポートする* .pdfファイル名を変更して、各PDFを個別にインポートする必要がありました( final.jmp) 。
- インポートするたびに、プロセスで作成して開いたすべての中間テーブルを閉じ、結果のテーブルを新しいものとして保存する必要がありますfinal.jmp 。
- その後、再度開きますfinal.jmp 、スクリプトを新しい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.5172, 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( 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( "Final" )
)
データ表スクリプティング再:複数のPDFファイルをインポートする可能なフロー:
- 単一のPDFファイルを処理する関数を作成します
- ディレクトリpdfディレクトリ内のすべてのファイルを取得します
- ディレクトリの最初のファイルを使用して、「コレクター」データテーブルを作成します
- 残りのファイルをループします
- 転置されたテーブルを作成されたコレクターデータテーブルに連結し、後で閉じます
たぶん、このようなものがうまくいくかもしれません:
Names Default To Here(1);
//directory where .pdf files exist
pdfDirectory = "C:\example folder\";
//function to open stack and transpose pdf file
stackTransposePdfFile = function({filePath}, {Default Local},
dtTemp = Open(
filePath,
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.5172, 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(0.7556, 4.7979, 7.5908, 8.2654))
)
)
);
//stack data table from pdf
dtTemp_stacked = dtTemp << Stack(
columns(:Column 3, :Column 4, :Column 5, :Column 6),
Source Label Column("Label"),
Stacked Data Column("Data"),
invisible
);
Close(dtTemp, no save); //close table created directly from pdf
//transpose table
dtTemp_transposed = dtTemp_stacked << Transpose(columns(:Data), invisible);
Close(dtTemp_stacked no save); //close stacked table
//return transposed table
return(dtTemp_transposed);
);
//list of files in directory (this assumes that there are only .pdf files)
pdfFile_list = Files In Directory(pdfDirectory);
//use the first table as "collection table"
finalDt = stackTransposePdfFile(pdfDirectory||pdfFile_list[1]);
//loop over files in pdfFile_list starting from second file
For(i = 2, i <= N Items(pdfFile_list), i++,
pdfDt = stackTransposePdfFile(pdfDirectory||pdfFile_list[i]);
finalDt << Concatenate(pdfDt, Append to first table);
Close(pdfDt, no save); //close transposed table
);
再:複数のPDFファイルをインポートするありがとう-このフォーラムがなければどこにいるのかわかりません。 素晴らしいもの!