title: coordinates (str) to list
body: <p>I have a very long txt file containing geographic coordinates..the format for each row looks like this:</p>
  
  <pre><code>501418.209 5314160.484 512.216
  501418.215 5314160.471 512.186
  501418.188 5314160.513 512.216
  </code></pre>
  
  <p>so separated by a blank (" ") and at the end a line break (\n)</p>
  
  <p>I need to import that file into a list...so far I only managed to import it as a string and then tried to converted in into a list. Unforunately, I have no idea how I can keep the formatting of the txt file, as I need to perform calculations on each row.</p>
  
  <p>My solution so far to import the txt file to a string variable:</p>
  
  <pre><code>fileobj = file(source,'r')
  data = ""
  for line in fileobj.readlines():
      linevals = line.strip().split(" ")
      data += "%s %s %s\n" % (linevals[0], linevals[1], linevals[2])
  print type(data)
  </code></pre>
  
  <p>And my solution for importing as list that didn't work:</p>
  
  <pre><code>fileobj = file(source,'r')
  data = []
  for line in fileobj.readlines():
      linevals = line.strip().split(" ")
      data.append(linevals)
  </code></pre>
  
  <p>On stackoverflow I found lots of solutions that suggested the <code>eval</code> function - but that didn't work as I need the whole row as one list element. Hope that was clear. Any solutions for this problem? I'm pretty newish to python, but that bothers me for quite some time now. Thank you!</p>