From 356f94591b4bf31281408f077f058d40868d4f58 Mon Sep 17 00:00:00 2001 From: Jyotiska NK Date: Thu, 20 Mar 2014 22:51:37 +0530 Subject: [PATCH] Added doctest for textFile method in context.py Doctest added for method textFile in context.py --- python/pyspark/context.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/python/pyspark/context.py b/python/pyspark/context.py index 90c3decbe4b01..d06cb8e70c230 100644 --- a/python/pyspark/context.py +++ b/python/pyspark/context.py @@ -258,6 +258,13 @@ def textFile(self, name, minSplits=None): Read a text file from HDFS, a local file system (available on all nodes), or any Hadoop-supported file system URI, and return it as an RDD of Strings. + + >>> path = os.path.join(tempdir, "sample-text.txt") + >>> with open(path, "w") as testFile: + ... testFile.write("Hello world!") + >>> textFile = sc.textFile(path) + >>> textFile.collect() + [u'Hello world!'] """ minSplits = minSplits or min(self.defaultParallelism, 2) return RDD(self._jsc.textFile(name, minSplits), self,