Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

wordcount pyspark

text_file = sc.textFile("hdfs://...")
counts = text_file.flatMap(lambda line: line.split(" ")) 
             .map(lambda word: (word, 1)) 
             .reduceByKey(lambda a, b: a + b)
counts.saveAsTextFile("hdfs://...")
Source by spark.apache.org #
 
PREVIOUS NEXT
Tagged: #wordcount #pyspark
ADD COMMENT
Topic
Name
5+7 =