Summary
We learned some useful tools for extracting and wrangling data from some common data sources here: documents (MS Word and PDF files) and spreadsheets (MS Excel files). The textract
package proved useful for extracting data from .docx
files, and works for .doc
and many other files as well, including reading scanned PDFs with OCR. We also learned that several other packages can be used to read text-encoded PDFs: pdfminer.six
, tika
, pymupdf
, and pypdf2
(among others). Recall that tika
will give us metadata from PDFs, but also requires Java to be properly installed on our system. Once we loaded text from documents, we saw how we can perform some basic analysis on them with n-grams and frequency plots in order to see a summary of the content of the documents.
The other major file type we examined was Excel spreadsheets. We saw how pandas
works well for simpler tasks, such as reading and writing simple Excel spreadsheets. For more complex tasks, we should use another package...