I have a huge project coming up for python, and I basically have to crunch a bunch of numbers and then output them into an organized text file. The text file will contain several columns, such as time, latitude/longitude, and elevation (its for a plane), and the problem is I don't know how to come up with a python program that does this, or even one that outputs a text file...
Help?!
1 reply to this topic
#1
Posted 26 July 2011 - 07:17 AM
|
|
|
#2
Posted 26 July 2011 - 12:35 PM
class File:
def __init__(self, name):
self.file = file(name, "w")
def write(self, time, position, elevation):
self.file.write("%02d:%02d:%02d : %s, %d\n" % (time.hour, time.minute, time.second, str(position), elevation))
def close(self):
self.file.close()
Then simply make a File object and use write method:
myFile = File("data.txt")
myFile.write(datetime.datetime.now(), (63.233627,-44.296875), 12500)
myFile.close() # don't forget to close the file when you're done!
In example above, write method would write time (hour, min and sec) with lat/long = 63.233627,-44.296875 and elevation of 12.5 km.Note: this was written off the top of my head, so there may be errors.
A conclusion is where you got tired of thinking.
#define class struct // All is public.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









