Let's start with the example of Shakespeare's "to be or not to be":
- Create the words directory by using the following command:
$ mkdir words
- Get into the words directory:
$ cd words
- Create the sh.txt text file and enter "to be or not to be" in it:
$ echo "to be or not to be" > sh.txt
- Start the Spark shell:
$ spark-shell
- Load the words directory as a DataFrame:
scala> val wdf = spark.read.text("file:///home/hduser/words")
- Convert wdf dataset into a dataset of strings wds :
scala> val wds = wdf.as[String]
It is very important to convert a DataFrame into a dataset before doing operations, which were done by RDDs in the past. DataFrame, essentially, is a collection of rows, and converting it into a more ...