Created
November 7, 2016 01:32
-
-
Save milindjagre/be9fbd62e2f82e7c106f79edecee0925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark import SparkConf, SparkContext | |
conf = SparkConf().setMaster("local").setAppName("Filter") | |
sc = SparkContext(conf = conf) | |
lines = sc.textFile("hdfs://localhost:54310/input.txt") | |
filter_lines = lines.filter(lambda x: "Milind" in x) | |
linecount = filter_lines.count() | |
i = 1 | |
for line in filter_lines.take(linecount): | |
print "-------" | |
print "LINE " , i , " " + line | |
i = i+1 | |
print "-------" | |
sc.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This python code filters the file input.txt on "Milind" keyword.