Extract lab results into a spreadsheet

Tracking a value across six months means having the values in a column rather than in six PDFs. This recovers the results table and writes figures a spreadsheet can chart.

A results table is a hard table

It has a two-deck header more often than not, a reference range column that is really two numbers in one cell, units in their own narrow column, and a flag column that is usually empty. Read as plain text the whole thing collapses into a line of words with no way to tell which space was a column boundary.

The grid here is found from where the words sit and where the white space runs down the page, which handles the awkward cases: a header spread over two decks, a merged cell spanning two columns, and a value broken across its own decimal point by a blurred scan, which is closed up rather than dropped.

A header band set in the same face and size as the body gives a recogniser nothing to work with, so it is found a third way: labels standing over columns of figures is what a header row is. A number anywhere in the first row settles it the other way.

Check every value against the paper

This is the strongest warning on any of these pages. A recogniser reading a printed report is confident about digits it has got wrong, and a decimal point moving one place in a lab value is the kind of error that looks entirely plausible in a cell.

Anything shaped like a number is written as a number so the column can be totalled or charted. A leading zero, a long unbroken run of digits and anything carrying a letter stay as text, because a sample identifier read as a quantity is worse than one left alone.

Can I combine six months of reports?

Add them all and each becomes its own sheet, which you can then stack in a spreadsheet.

Is this a diagnosis tool?

No. It moves numbers from a page into a spreadsheet and nothing more.

Support and billing: support@gosmartpdf.com. Operated by Mrityunjay Kumar, India. Payments by Dodo Payments, our merchant of record.

Loading the editor…