When I ran below code in pyspark it working fine and giving result, but while saving as textfile giving error as below. Pls suggest.
football = sc.textFile("/user/nikkhiel123/footballtab")
ootBallAL = football.filter(lambda rec: (rec.split("\t")[2] == “AL”))
footballMap1 = footBallAL.map(lambda rec: (float(rec.split("\t")[4]), rec))
topPlayers = footballMap1.sortByKey(False).map(lambda rec: rec[1]).take(5)
for i in topPlayers: print(i)
result
2009 NYA AL rodrial01 3.3E7
2010 NYA AL rodrial01 3.3E7
2008 NYA AL rodrial01 2.8E7
2005 NYA AL rodrial01 2.6E7
2010 NYA AL sabatcc01 2.42857E7
error after below save command
topPlayers.saveAsTextFile("/user/nikkhiel123/football/topPlayers")
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘list’ object has no attribute ‘saveAsTextFile’