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
  • 32,481
  • 14
  • 91
  • 120
Pedro Alves
  • 960
  • 1
  • 16
  • 31

1 Answers1

1

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
  • 32,481
  • 14
  • 91
  • 120