Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import os
os.system("rm out Rplots.pdf")
os.system("python process.py > out")
os.system("Rscript plot.r")
os.system("mv Rplots.pdf caca.pdf")
def es_linea_de_fin_header(line) :
return line == "*END*"
def es_linea_de_latitud(line):
return line.startswith("* NMEA Latitude =")
def obtener_latitud_de_linea(line) :
words = line.split("=")
return words[1].strip()
def sumar_latitud(line):
lista = line.split("=")
#02 00.00 S
coord = lista[1].strip()
elements = coord.split(" ")
first_number = int(elements[0])
first_number = first_number + 1
return lista[0] + "= " + "{0:02d}".format(first_number) + " " + elements[1] + " " + elements[2]
def print_archivo_sin_header(name, index1, index2) :
f = open(name, "r")
#procesamiento del header
for line in f:
line = line.strip()
if es_linea_de_fin_header(line) :
break
for line in f:
line = line.strip()
print reduce_line(line, index1, index2)
f.close()
def reduce_line(line, index1, index2) :
lista = line.split()
nueva = lista[index1] + " " + lista[index2]
return nueva
out <- read.table("~/pclass/out", quote="\"", comment.char="")
plot(out[,1], out[,2])
import sys
import edwin
edwin.print_archivo_sin_header("PIRA001.cnv", 3, 4)
from edwin import sumar_latitud
test1 = "* NMEA Latitude = 02 00.07 S"
expected_result = "* NMEA Latitude = 03 00.07 S"
result = sumar_latitud(test1)
print test1
print result
if result == expected_result :
print "exito"
else:
print "fuck"
line = "11783 236.335774 -0.298 1.415 27.0529 27.0544 5.707486 5.707238 2.6472 1.407 0.000e+00"
lista = line.split()
nueva = lista[3] + " " + lista[4]
print nueva
import sys
import edwin
name = "PIRA001.cnv"
f = open(name, "r")
#procesamiento del header
for line in f:
line = line.rstrip()
if edwin.es_linea_de_latitud(line) :
print edwin.sumar_latitud(line)
else :
print line
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.