Handling Unstructured Data
Unstructured data usually refers to data that doesn’t have a fixed format. CSV files are structured, for example, and JSON files can also be considered structured, although not tabular. Computer logs, on the other hand, don’t have the same structure, as different programs and daemons will output messages without a common pattern. Images are also another example of unstructured data, like free text.
We can leverage Spark’s flexibility for reading data to parse unstructured formats and extract the required information into a more structured format, allowing analysis. This step is usually called pre-processing or data wrangling.
Exercise 23: Parsing Text and Cleaning
In this exercise, we will read a text file, split it into lines and remove the words the and a from the string given string:
Read the text file shake.txt (https://raw.githubusercontent.com/TrainingByPackt/Big-Data-Analysis-with-Python/master/Lesson03/data/shake.txt) into the Spark object using the text method...