title: Issue in spliting data in Txt file while converting from RDD to DataFrame in Spark using Scala
body: <p>I reading data from a text file as RDD and converting into DataFrame but I am not getting the desired output.</p>
  
  <p>Code -</p>
  
  <pre><code>val myFile = sc.textFile("car.txt")
  val df = myFile.map(_.split(" ")).map(line =&gt; Text(line(0))).toDF()
  df.show()
  </code></pre>
  
  <p>where Text is the case class</p>
  
  <p>case class-</p>
  
  <pre><code>case class Text(field: String)
  </code></pre>
  
  <p>Data in the car.txt file -</p>
  
  <pre><code>hyundai honda
  honda maruti
  maruti honda
  </code></pre>
  
  <p>Output when executing -</p>
  
  <pre><code>+-------+
  |  field|
  +-------+
  |hyundai|
  |  honda|
  | maruti|
  +-------+
  </code></pre>
  
  <p>Why am I not getting all the data from the text file in the DataFrame?</p>