주요 콘텐츠

textFile

R2026b

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

(To be removed) Create an RDD from a text file

matlab.compiler.mlspark.SparkContext.textFile will be removed in a future release. There is no replacement functionality. For more information, see Version History.

Syntax

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

Description

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.

Examples

expand all

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

%% textFile
rdd = sc.textFile('airlinesmall.csv')

Version History

Introduced in R2016b

collapse all