title: java.lang.NumberFormatException: For input string: "" while creating Dataframe
body: <p>I am using cloudera vm. I have imported the products table from <code>retail_db</code> as a <code>textfile</code> with <code>'|'</code> as a fields separator (using sqoop).</p>
  
  <p>Following is the table schema:</p>
  
  <pre><code>mysql&gt; describe products;
  product_id: int(11)
  product_category_id: int(11)
  product_name: varchar(45)
  product_description: varchar(255)
  product_price: float
  product_image: varchar(255)
  </code></pre>
  
  <p>I want to create a Dataframe from this data.</p>
  
  <p>I got no issue while using following code:</p>
  
  <pre><code>var products = sc.textFile("/user/cloudera/ex/products").map(r =&gt; {var p = r.split('|'); (p(0).toInt, p(1).toInt, p(2), p(3), p(4).toFloat, p(5))})
  case class Products(productID: Int, productCategory: Int, productName: String, productDescription: String, productPrice: Float, productImage: String)
  var productsDF = products.map(r =&gt; Products(r._1, r._2, r._3, r._4, r._5, r._6)).toDF()
  
  productsDF.show()
  </code></pre>
  
  <p>But I got <code>NumberFormatException exception</code> for following code:</p>
  
  <pre><code>case class Products (product_id: Int, product_category_id: Int, product_name: String, product_description: String, product_price: Float, product_image: String)
  val productsDF = sc.textFile("/user/cloudera/ex/products").map(_.split("|")).map(p =&gt; Products(p(0).trim.toInt, p(1).trim.toInt, p(2), p(3), p(4).trim.toFloat, p(5))).toDF()
  productsDF.show()
  </code></pre>
  
  <blockquote>
    <p>java.lang.NumberFormatException: For input string: ""</p>
  </blockquote>
  
  <p>Why is that I am getting exception in 2nd code even though it is same as that of 1st one?</p>