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
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):
       global gpsd
       self.current_value = None
       self.running = True
   def run(self):
       global gpsd
       while gpsp.running:
if  __name__ == '__main__':
       while True:
           f.write(str(gpsd.fix.longitude) + ',' + str(gpsd.fix.latitude) + "\n")
       gpsp.running = False

Possibly Related Threads…
Thread Author Replies Views Last Post
  List / arrays putting in sentence Kurta 3 1,002 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 761 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  saving data from text file to CSV file in python having delimiter as space K11 1 873 Sep-11-2020, 06:28 AM
Last Post: bowlofred
  Trouble with reading csv file and putting it into a file Milfredo 3 1,036 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 937 Jun-26-2020, 11:59 AM
Last Post: Mangesh121
  Process Data from one csv file and write to another CSV file specific column ajin9581 1 960 Jun-17-2020, 06:00 PM
Last Post: buran
  Putting a condition Jiwan 3 1,325 Apr-25-2020, 11:28 AM
Last Post: anbu23
  Putting frames on separate lines kenwatts275 3 1,116 Dec-16-2019, 04:52 PM
Last Post: kenwatts275
  reading txt file putting in list function Expel 7 1,772 Jul-17-2019, 03:18 PM
Last Post: Expel
  Putting text on images from excel/csv file sam77am 1 1,126 Apr-05-2019, 07:36 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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