NLinker icon

pyspark wordcount

NLinker | PRO | 12/07/19 05:21:46 AM UTC | 0 ⭐ | 925 👁️ | Never ⏰ | []
Python |

250 B

|

None

|

0 👍

/

0 👎

words = sc.textFile("D:/workspace/spark/input.txt")
          .flatMap(lambda line: line.split(" ")) 
wordCounts = words.map(lambda word: (word, 1))
                  .reduceByKey(lambda a,b: a + b)
wordCounts.saveAsTextFile("D:/workspace/spark/output/")

Comments