Article directory
1. Spark reads local files
Sometimes we want to directly read the local file for processing, then we can use textFile
this method, which can read the file of the specified path, and then convert it into the RDD data type in Spark.
But one thing to note here is what is local. If your code is running in windows, then your local path is C drive, D drive. If you are running code in Linux, then the local path is the path in Linux. If you /home/data
want To read the HDFS path, you can also just need to configure URL parameters.
1. Function introduction
textFile
is a function in Spark that reads data from a text file and creates an RDD. It can be used to load text data with each line of text as an element in the RDD. The following is textFile
a detailed description of the function and its parameters:
def textFile