Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

ATELIER RDD

1—

rdd = sc.textFile("atelier1/purchases.txt")

rdd.getNumPartitions()

rdd2_coalesce = rdd.coalesce(4)

rdd2_coalesce.getNumPartitions()

tab = rdd.map(lambda x : x.split("\t"))

tab.map(lambda n: (str(n[2]), float(n[4]) ) ).reduceByKey(lambda v1,v2: v1 + v2).collect()

2---

logFile = sc.textFile("atelier1/error_log.txt")

error = logFile.filter(lambda line: "ERROR" in line)

error.count()

error.filter(lambda line: "php" in line).collect()

error.toDebugString()

You might also like