Working conversion of csv files.

This commit is contained in:
id101010
2014-11-16 03:14:38 +01:00
parent a8cf5243cb
commit 9833620f1a

50
gsc.py
View File

@@ -274,7 +274,6 @@ class GPRMC(object):
return gprmc return gprmc
if __name__ == "__main__": if __name__ == "__main__":
'''
# Test koordinaten UNI Bern in WGS84 # Test koordinaten UNI Bern in WGS84
# Sexagesimal: Länge 7° 26' 22.50" / Breite 46° 57' 08.66" # Sexagesimal: Länge 7° 26' 22.50" / Breite 46° 57' 08.66"
# Decimal: Länge 7.438808 / Breite 46.951286 # Decimal: Länge 7.438808 / Breite 46.951286
@@ -284,36 +283,29 @@ if __name__ == "__main__":
testlng = 7.360393 testlng = 7.360393
lv03 = [0,0,0] lv03 = [0,0,0]
converter = GPSConverter() converter = GPSConverter()
lv03 = converter.WGS84toLV03(testlat, testlng, 0) lv03 = converter.WGS84toLV03(testlat, testlng, 0)
print lv03 print lv03
'''
converter = GPSConverter()
try: testfile="/home/aaron/Downloads/Test.csv"
Testfile="/home/aaron/GPS_ZUGKRAFTMESSUNG/20140910_Guellen/GPS_Guellen.txt" lines = csv.reader(open(testfile, 'r'))
sentences = csv.reader(open(Testfile, 'r'))
for i, line in enumerate(lines):
# for each line in the file if line:
for j, line in enumerate(sentences): print "[%d ----------------------------------]: " % i
# if the line isn't empty and begins with '$GPRMC' for words in line:
if line and line[0].strip() == '$GPRMC': for j, word in enumerate(words.split(',')):
print "__________________________\n" #print "[%d]: " % j + "%s" % word
print "[Element: %d]" % j if(j == 3):
for i, word in enumerate(line): lat = float(word)
#print "[%d]" % i + word lat = lat/100
if i == 3: if(j == 5):
tmp = float(word) lon = float(word)
tmp = tmp / 100 lon = lon/100
print "lat: %f" % tmp if(j == 6):
if i == 5: lv03 = converter.WGS84toLV03(lat, lon, 0)
tmp = float(word) print "[WGS84]: " + "%fN" % lat + " %fE" % lon
tmp = tmp / 100 print "[LV03]: " + "%f" % lv03[0] + " %f" % lv03[1]
print "lon: %f" % tmp
except Exception as e:
print e
finally:
print "[DEBUG]: Cleanup done, exiting."