Valid CCA175 Dumps shared by EduDump.com for Helping Passing CCA175 Exam! EduDump.com now offer the newest CCA175 exam dumps, the EduDump.com CCA175 exam questions have been updated and answers have been corrected get the newest EduDump.com CCA175 dumps with Test Engine here:
CORRECT TEXT Problem Scenario 34 : You have given a file named spark6/user.csv. Data is given below: user.csv id,topic,hits Rahul,scala,120 Nikita,spark,80 Mithun,spark,1 myself,cca175,180 Now write a Spark code in scala which will remove the header part and create RDD of values as below, for all rows. And also if id is myself" than filter out row. Map(id -> om, topic -> scala, hits -> 120)
Correct Answer:
See the explanation for Step by Step Solution and configuration. Explanation: Solution : Step 1 : Create file in hdfs (We will do using Hue). However, you can first create in local filesystem and then upload it to hdfs. Step 2 : Load user.csv file from hdfs and create PairRDDs val csv = sc.textFile("spark6/user.csv") Step 3 : split and clean data val headerAndRows = csv.map(line => line.split(",").map(_.trim)) Step 4 : Get header row val header = headerAndRows.first Step 5 : Filter out header (We need to check if the first val matches the first header name) val data = headerAndRows.filter(_(0) != header(O)) Step 6 : Splits to map (header/value pairs) val maps = data.map(splits => header.zip(splits).toMap) step 7: Filter out the user "myself val result = maps.filter(map => mapf'id") != "myself") Step 8 : Save the output as a Text file. result.saveAsTextFile("spark6/result.txt")