Main Content


Class: matlab.compiler.mlspark.SparkContext
Namespace: matlab.compiler.mlspark

Create an RDD from a text file


rdd = textFile(sc,pathToFile)
rdd = textFile(sc,pathToFile,minPartitions)


rdd = textFile(sc,pathToFile) creates an RDD from a text file located in pathToFile.

rdd = textFile(sc,pathToFile,minPartitions) creates an RDD with minimum partitions specified by minPartitions.

Input Arguments

expand all

The SparkContext to use, specified as a SparkContext object.

File path to text file, specified as a character vector enclosed in ''.

Data Types: char | string

Minimum number of partitions to be created, specified as a scalar.

Data Types: double

Output Arguments

expand all

An output RDD created from reading in a text file, returned as an RDD object.


expand all

%% Connect to Spark
sparkProp = containers.Map({'spark.executor.cores'}, {'1'});
conf = matlab.compiler.mlspark.SparkConf('AppName','myApp', ...
sc = matlab.compiler.mlspark.SparkContext(conf);

%% textFile
rdd = sc.textFile('/<matlabroot>/toolbox/matlab/demos/airlinesmall.csv')

Version History

Introduced in R2016b