title: How to create a DataFrame from a text file in Spark
body: <p>I have a text file on HDFS and I want to convert it to a Data Frame in Spark.</p>
  
  <p>I am using the Spark Context to load the file and then try to generate individual columns from that file. </p>
  
  <pre><code>val myFile = sc.textFile("file.txt")
  val myFile1 = myFile.map(x=&gt;x.split(";"))
  </code></pre>
  
  <p>After doing this, I am trying the following operation.</p>
  
  <pre><code>myFile1.toDF()
  </code></pre>
  
  <p>I am getting an issues since the elements in myFile1 RDD are now array type.</p>
  
  <p>How can I solve this issue?</p>