0

I am using a raspberry pi B+ with a GPS module to output GPS details to a textfile.

Here are some links to understand the attributes in use:

http://python3-microstacknode.readthedocs.org/en/latest/example.html#l80-gps http://aprs.gids.nl/nmea/

Here is my code:

##Prints the latitude and longitude every second.
import time
import microstacknode.hardware.gps.l80gps

if __name__ == '__main__':
    gps = microstacknode.hardware.gps.l80gps.L80GPS()
    while True:
        data = gps.get_gpgga()
        print(data.values())
        text_file = open("/home/pi/fyp/gps.txt", "w")
        text_file.write(data.values())
        text_file.close()
        time.sleep(1)

Here is my output:

$GPGGA,012939.800,,,,,0,0,,,M,,M,,*40

dict_values(['', '', '', '0', '', 12939.8, '0', 0.0, '$GPGGA', 0.0, '', '', ''])
Traceback (most recent call last):
  File "gps.py", line 11, in <module>
    text_file.write(data.values())
TypeError: must be str, not dict_values

How do I get the output to be put into a textfile?

1 Answers1

0
text_file.write(",".join(map(str,data.values())))

Just do a join on ,

vks
  • 67,027
  • 10
  • 91
  • 124