How to extract data from PDF that contains a plot and a table

103 views (last 30 days)
Hi,
I have thousands of PDFs that has similar format to the one attached. It starts with a plot, then it has a summary table with values.
I need to be able to extract the numbers in the table and store them in a matrix to be processed later (can exclude first column due to the word "average"). I will also need to be able to loop/read through the pdfs and extract the numbers. the PDF's name are in a number sequential order.
I have tried several things and it didn't work. I will appreciate any help. Thanks in advance.
  2 Comments
sherry james
sherry james on 28 Dec 2018
Hi,
As you said you want to extract the numbers present in the table then you should use some application that can easily extract data from PDF. Once such utility is SysTools PDF Toolbox Software. With this software you can extract numbers from multiple PDF documents and the data for each individual PDF is saved in the seperate .txt document.
Visit the link & extract numbers: https://www.systoolsgroup.com/pdf-toolbox.html
Camila Coria
Camila Coria on 3 Jan 2019
Thanks but was hoping to not need another software to keep things easier for future users.

Sign in to comment.

Answers (3)

Surbhi Pillai
Surbhi Pillai on 31 Dec 2018
Hi Camila
You can refer to the below MATLAB Answers link to understand the extraction of data from a pdf file in MATLAB.
I hope this helps....

DGM
DGM on 29 Nov 2023
fname = '35517.001.pdf';
str = extractFileText(fname);
% get the main table
T = extractBetween(str,'Dmax','AVERAGE');
T = strcat('Dmax',T);
T = split(T,newline);
% get rid of empty lines, reshape
mk = ~cellfun('isempty',T);
T = T(mk);
T = reshape(T,[],7);
% get the last row (the column averages)
lastrow = extractAfter(str,'AVERAGE');
lastrow = split(lastrow,newline);
% get rid of empty lines, reshape
mk = ~cellfun('isempty',lastrow);
lastrow = lastrow(mk);
lastrow = reshape(lastrow,[],7);
% convert to numeric data
data = str2double(T(2:end,:))
data = 3×7
1.0e+03 * 0.0400 0.0636 0.0016 0.0107 2.2365 0.0012 0.1465 0.0401 0.0588 0.0015 0.0092 1.8422 0.0012 0.1539 0.0400 0.0571 0.0014 0.0085 1.7045 0.0012 0.1543
averages = str2double(lastrow)
averages = 1×7
1.0e+03 * 0.0400 0.0599 0.0015 0.0095 1.9278 0.0012 0.1516
% extract column headers if you want to make a table or something
headers = T(1,:)
headers = 1×7 string array
"Dmax(cm)" "Fmax(t)" "Keff(t/cm)" "Qd(t)" "EDC(t.cm)" "K2fit(t/cm)" "V(cm/min)"
Generally, it's not that simple. See also:
You can't generally rely on tabular data being presented in the expected order. In my experience, it's not even guaranteed that a set of similar-looking related files has a consistent ordering. I don't know how extractFileText() works, but I bet that you will have to check the integrity of all your extracted data if you want to be sure it's not mixed up nonsense.

adam
adam on 29 Nov 2023
try pdf champ

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!