LogoLogo
The Fundamentals of Data-driven Storytelling
The Fundamentals of Data-driven Storytelling
  • About this course
    • Course Introduction
  • Module 1 - Find
    • 1.1 How to Find Data for Storytelling and journalism
      • Starting with a question
      • Open data portals and platforms
      • Other sources of data
    • 1.2 How to get better data from a Goolge Search
      • Searching for filetypes and formats
      • More on Advanced Search operators
      • Other common Google Search operators
    • 1.3 Sourcing your own data
      • Creating a Google Form for Research
      • Creating a questionnaire with TypeForm
      • Using quizzes and comments as a sources of data
  • Module 2 - Get
    • 2.1 Turning websites and PDFs into machine readable data
      • Scraping data with Tabula
    • 2.2 An introduction to spreadsheet software
      • Google Sheets, Microsoft Excel and Libre Office Calc.
      • Finding your way around a spreadsheet
      • Simple web scraping with Google Sheets
  • Module 3 - Verify
    • 3.1 Can I use this data in my work?
      • Initial steps for verification
      • What do these column headings mean?
  • Module 4 - Clean
    • 4.1 What to do with disorganised data?
      • Why is clean data important?
      • Keep your data organised
      • Cleaning data cheatsheet
  • Module 5 - Analyse
    • 5.1 What is the story within the data?
      • Spreadsheet rows, columns, cells and tabs
        • Spreadsheet formats, forumlas and essential shortcuts
          • Using the VLOOKUP Function
            • Combine Data From Multiple Spreadsheets
    • 5.2 How to turn numbers into stories
  • Module 6 - Visualise
    • 6.1 Ways we visualise data
    • 6.2 Why we visualize Data
    • 6.3 How to visualise data
  • Course Testing & Feedback
    • ⏱️Quick course exam
    • 🎓Extended course exam
    • 📝Survey and feedback
Powered by GitBook
On this page
  1. Module 2 - Get
  2. 2.1 Turning websites and PDFs into machine readable data

Scraping data with Tabula

Previous2.1 Turning websites and PDFs into machine readable dataNext2.2 An introduction to spreadsheet software

Last updated 2 years ago

Much data is published in the PDF format. PDFs are highly versatile filetypes, and can contain text and images. Unlike, say, Word documents, copy and pasting text and numbers from a PDF document rarely works. When a scanned document is shared as a PDF, copy and paste won't work at all.

Here is a simple example from the Department of Labour - .

This PDF contains a table, with the bid number, tender value and winning organisation. But how do we copy that into a spreadsheet when the document is actually just an image with no "text"?

Using Tabula

The answer is that we need an application such as Tabula, which is specifically designed to extract tables from PDFs

Once you've imported the file, click on Extract Data. Your screen should look like this.

Tabula is very easy to use. Simply use your mouse to drag a selection rectangle around the table you want to extract.

And then click Preview & Export Extracted Data. Your screen should look like this.

In this instance, you can see that the table hasn't extracted cleanly. The text is split over rows that don't appear in the original, making it hard to analyse. You can change the way Tabula performs its data extracion by clicking on the Stream/Lattice buttons

.

This example use a very simple (although somewhat poor quality) PDF, but Tabula can extract large tables too. It can even extract tables that are split over multiple pages of a PDF.

You can download . You'll find installation instructions on the same site. Once you have installed it, Tabula doesn't run like a normal desktop application, it is accessed through your web browser (usually by browsing to )

Download the . Once you have Tabula running, open it using the Browse button in this view.

The only thing it cannot do is Optical Character Recognition (OCR). OCR is a technique by which computers can "read" images and look for letters and numbers. It may work with some scanned documents, but not all. If not, you will likely need to use paid for software, such as Adobe Acrobat or an application based on the open source libraries.

Try it with this . It's a 222 page document, but almost all the important data is in identical tables from page 13 on. In this case, you can extract an awful lot of data at once, but you may well still need to clean it a little once it has been imported into your spreadsheet app.

Tabula here
http://127.0.0.1:8080
PDF file we showed you above
Tesseract
National Senior Certificate (Matric) report from South Africa's Department of Basic Education
you can download the original file here