Python Forum
Putting GPS data into a file
Thread Rating:
  • 4 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Putting GPS data into a file
#1
my question here
I am trying to input data that streams from a GPS module into a file. The file locations.csv opens OK but stays blank with no data input into the file!

from gps import *
import time
import threading
f = open("locations.csv","w")
gpsd = None
class GpsPoller(threading.Thread):
   def __init__(self):
       threading.Thread.__init__(self)
       global gpsd
       gpsd=gps(mode=WATCH_ENABLE)
       self.current_value = None
       self.running = True
   def run(self):
       global gpsd
       while gpsp.running:
           gpsd.next()
if  __name__ == '__main__':
   gpsp=GpsPoller()
   try:
       gpsp.start()
       while True:
           f.write(str(gpsd.fix.longitude) + ',' + str(gpsd.fix.latitude) + "\n")
           time.sleep(30)
   except(KeyboardInterrupt,SystemExit):
       f.close()
       gpsp.running = False
       gpsp.join()
Reply


Messages In This Thread
Putting GPS data into a file - by kendias - May-28-2017, 06:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List / arrays putting in sentence Kurta 3 2,564 Dec-25-2020, 11:29 AM
Last Post: Larz60+
  xml file creation from an XML file template and data from an excel file naji_python 1 2,106 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  Trouble with reading csv file and putting it into a file Milfredo 3 2,264 Sep-04-2020, 05:30 AM
Last Post: Milfredo
  How to save CSV file data into the Azure Data Lake Storage Gen2 table? Mangesh121 0 2,109 Jun-26-2020, 11:59 AM
Last Post: Mangesh121
  Putting a condition Jiwan 3 2,722 Apr-25-2020, 11:28 AM
Last Post: anbu23
  Grabbing comma separed values from SQLite and putting them in a list PythonNPC 8 4,014 Apr-10-2020, 02:39 PM
Last Post: buran
  Putting frames on separate lines kenwatts275 3 2,426 Dec-16-2019, 04:52 PM
Last Post: kenwatts275
  reading txt file putting in list function Expel 7 3,754 Jul-17-2019, 03:18 PM
Last Post: Expel
  Putting text on images from excel/csv file sam77am 1 2,192 Apr-05-2019, 07:36 AM
Last Post: Larz60+
  Putting an array for each string that is printed to a loop ClaudioSimonetti 1 2,338 Feb-05-2019, 12:52 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020