Warning: I am new to scripting
Challenge:
Work flow & issues:
Question:
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" ) )
All that has to be done is to just loop across the code, reading in one file after another and adding it to the Final data table. The JSL below should provide you with a good start on how to do this.
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 );
);
All that has to be done is to just loop across the code, reading in one file after another and adding it to the Final data table. The JSL below should provide you with a good start on how to do this.
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 );
);
@txnelson, I don't know how to adequately express my gratitude. You are very, very kind. Thank you so much for your help again!
Sorry, I have to return with yet more questions because somehow, despite years of academic training, I cannot get this loop to function. Here's what I tried to make it work: First I moved all files to my local hard disk, because for some reason we are using "()" in some of our folder names on the server and I had the impression this was creating an issue. Eventually, I "quoted" the whole directory in the script using quotation marks, which seemed to convince the script to run until the next error message. Then it told me something about "Path is invalid ...'Glue' ...". I googled it, but have no idea how to address that issue. I can see that the file name in the error message is the name of one of the files in the directory I want to work with. First I thought the hyphen in the file name was creating an issue, but even when changing that the error occurs.
I have pasted in below:
Also, how do I include the directory AND filename in the final data table?
Thank you very much in advance! (If you find this too trivial to answer, I will understand.)
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 );
);
My error........
Data table( "Final" );
should have been specified
New Table( "Final" );