I am just starting to learn Spark so please bear with me if this is too obvious.
I installed spark and I am able to run it in a terminal (by "./bin/pyspark").
But I fail to try the following example (word count):
path = os.path.join("sample-text.txt")
with open(path, "w") as testFile:
_ = testFile.write("Hello world Hello")
file = sc.textFile(path)
counts = file.flatMap(lambda line: line.split(" ")) \
.map(lambda word: (word, 1)) \
.reduceByKey(lambda a, b: a + b)
path2 = os.path.join("word-count.txt")
counts.saveAsTextFile(path2)
Everything went through, but when I was trying to open the output word-count.txt file, it says that this document cannot be opened.
What am I doing wrong?