Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bobquest33/7940d3ec4ea85e7087f0db9695c9400f to your computer and use it in GitHub Desktop.
Save bobquest33/7940d3ec4ea85e7087f0db9695c9400f to your computer and use it in GitHub Desktop.
#Basic Non Empty line count example
#Read a text file and create RDD lines
lines = sc.textFile("wordtxt.txt")
#Use tranformation function filter to create notEmptyLines from lines
notEmptyLines = lines.filter(lambda line:len(line)>0)
#Execute action count to save the count of non empty lines to count
#And print it
count = notEmptyLines.count()
print(count)
#Sample output
#500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment