Re: NumberFormatException while reading and split the file

2018-04-04 Thread utkarsh_deep
Response to the 1st approach: When you do spark.read.text("/xyz/a/b/filename") it returns a DataFrame and when applying the rdd methods gives you a RDD[Row], so when you use map, your function get Row as the parameter i.e; ip in your code. Therefore you must use the Row methods to access its

NumberFormatException while reading and split the file

2018-04-04 Thread anbu
1st Approach: error : value split is not a member of org.apache.spark.sql.Row? val newRdd = spark.read.text("/xyz/a/b/filename").rdd anotherRDD = newRdd. map(ip =>ip.split("\\|")).map(ip => Row(if (ip(0).isEmpty()) { null.asInstanceOf[Int] }