title: NMEA data parsing using python 2.7
body: <p>i want readings of present GPS location, when i run the below code in raspberry pi,  program prints 10-12 outputs and then it displays the error as below: <br>
    <strong>Traceback (most recent call last):<br>
    File "simplegpsparsing.py", line 24, in <br>
      get_present_gps() <br>
    File "simplegpsparsing.py", line 16, in get_present_gps<br>
      lat, _, lon= line.split(',')[2:5]<br>
  ValueError: need more than 0 values to unpack<br></strong>
  i want present value of GPS( buffers should be updated with immediate GPS) so that present GPS  values can be known.
  my code goes as below :<br></p>
  
  <pre><code>import os
  import serial
  def get_present_gps:
      ser= serial.Serial('/dev/ttyAMA0',9600)
      ser.open()
      while True :
          f=open('/home/pi/Desktop/gps1','w')
          data=ser.read(ser.inWaiting()) # read no.of bytes in waiting
          f.write(data) #write data into file
          f.flush() # flush(method) from buffer into os buffer
          os.fsync(f.fileno()) #ensure to write from os buffer(internal buffers)into disk
          f = open('/home/pi/Desktop/gps1','r') # fetch the required file
          for line in f.read().split('\n') :  
              if line.startswith( '$GPGGA' ) :
                  lat, _, lon = line.strip().split(',')[2:5]
                  try :
                      lat = float( lat )
                      lon = float( lon )
                      print lat
                      print lon
                  except :
                      pass
  
           # something wrong happens with your data, print some error messages
  get_present_gps()             
  </code></pre>
  
  <p>if the serial port is left open without closing, will it create any problem? will  the above code meet my requirement i.e getting the instantaneous value?</p>