1

I've the following tranformation:

rdd1.map(lambda line: line[3]).countByValue()

How I can I store this in order to save the result as TextFile?

Because if I try to use:

rdd1.map(lambda line: line[3]).countByValue().saveAsTextFile("directory.txt")

However, the saveAsTextFile is not a part of collections. How can I do this?

Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121
Pedro Alves
  • 1,004
  • 1
  • 21
  • 47

1 Answers1

0

countByValue() converts result in a Map collection not a RDD.

saveAsTextFile() is defined to work on a RDD, not on a map/collection.

similar question with scala(countByKey) is here

you need to parallelize map and create a RDD and then save as text file

Ram Ghadiyaram
  • 28,239
  • 13
  • 95
  • 121