Spark reads local files

insert image description here


1. Spark reads local files

Sometimes we want to directly read the local file for processing, then we can use textFilethis 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/datawant To read the HDFS path, you can also just need to configure URL parameters.

1. Function introduction

textFileis 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 textFilea detailed description of the function and its parameters:

def textFile

Guess you like

Origin blog.csdn.net/m0_47256162/article/details/132283376