Skip to content

Commit 8fe6ca9

Browse files
author
madsh01
committed
practice 1
1 parent 83216e1 commit 8fe6ca9

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

rdd/WordCount_p.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pyspark import SparkConf,SparkContext
2+
3+
4+
if __name__ == "__main__":
5+
print("hipy")
6+
conf= SparkConf().setAppName("word count").setMaster("local[*]")
7+
sc= SparkContext(conf= conf)
8+
lines = sc.textFile("in/word_count.text")
9+
10+
words = lines.flatMap(lambda line: line.split(" "))
11+
wordCounts = words.countByValue()
12+
for word,count in wordCounts.items():
13+
print("{}:{}".format(word,count))

0 commit comments

Comments
 (0)