Skip to content

Instantly share code, notes, and snippets.

@wittyfilter
Created April 9, 2014 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wittyfilter/10222160 to your computer and use it in GitHub Desktop.
Save wittyfilter/10222160 to your computer and use it in GitHub Desktop.
import string
tfile = open("/home/pi/minicomfile","r")
text = tfile.read()
length = len(tfile.readline())
tfile.close()
temperaturedata = text.split("\n")[length - 1]
floatdata = string.atof(temperaturedata)
temperature = floatdata / 10
intdata = int(temperature)
intdata = '%d' %intdata
output = open('/home/pi/data', 'w')
output.write(intdata)
output.close
res = '{"value":%f}' %temperature
output = open('/home/pi/datafile.txt', 'w')
output.write(res)
output.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment