Skip to content
Snippets Groups Projects
Commit 39dd953f authored by Josh Rosen's avatar Josh Rosen
Browse files

Add test for pyspark.RDD.saveAsTextFile().

parent 59195c68
No related branches found
No related tags found
Loading
...@@ -351,10 +351,17 @@ class RDD(object): ...@@ -351,10 +351,17 @@ class RDD(object):
""" """
return self.take(1)[0] return self.take(1)[0]
# TODO: add test and fix for use with Batch
def saveAsTextFile(self, path): def saveAsTextFile(self, path):
""" """
Save this RDD as a text file, using string representations of elements. Save this RDD as a text file, using string representations of elements.
>>> tempFile = NamedTemporaryFile(delete=True)
>>> tempFile.close()
>>> sc.parallelize(range(10)).saveAsTextFile(tempFile.name)
>>> from fileinput import input
>>> from glob import glob
>>> ''.join(input(glob(tempFile.name + "/part-0000*")))
'0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n'
""" """
def func(iterator): def func(iterator):
return (str(x).encode("utf-8") for x in iterator) return (str(x).encode("utf-8") for x in iterator)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment