title: How to create columns from a text file containing strings with spaces?
body: <p>I want to read a file in pyspark and create a dataframe out of it. It is a tsv file with the values in the form of:</p>
  
  <pre><code>2015-07-22T09:00:28.019143Z "strings with space" "strings with space" ECDHE THRGH
  </code></pre>
  
  <p>I tried to create row objects and converting those to dataframe. But I am stuck with how to split the data and create columns. Data contains strings with spaces.</p>
  
  <pre><code>from pyspark.sql import Row
  from pyspark.sql import SparkSession
  import re
  
  spark = SparkSession \
      .builder \
      .appName("Task1") \
      .getOrCreate()
  
  sc = spark.sparkContext
  
  # Load a text file and convert each line to a Row.
  lines = sc.textFile("file.tsv")
  #parts = lines.map(lambda l: l.split(" ")) -- Tried this but it doesn't give correct output as there are spaces in strings.
  values = lines.map(lambda p: Row(value=re.findall(r'\"(.+?)\"', str(p))[0].replace(" ","")))
  </code></pre>
  
  <p>The ideal results would be a dataframe as below :</p>
  
  <pre><code>Timestamp                          val1              val2      
   val3       val4
  2015-07-22T09:00:28.019143Z strings with space strings with space ECDHE THRGH
  </code></pre>