Raspberry Pi Zero Cookbook by Snajder Edward

Raspberry Pi Zero Cookbook by Snajder Edward

Author:Snajder, Edward [Snajder, Edward]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2017-03-24T04:00:00+00:00


Because we aren't calling any other functions, we really only need to look at the new rpztempcsvexport function. We will need the strptime function to convert our string to a time and then the strftime function to turn it into a good format for a CSV file (YYYYMMDD HH:mm:ss TZ). The final part of the loop puts the date/time data into a nested list: def rpztempcsvexport(): from time import strptime, strftime import csv csvdata = [[]] for row in open(templog): data = row.replace("RPZ Temperature at ","").split(": ") humandate = data[0] pydate = strptime(humandate,'%a %d %b %H:%M:%S %Z %Y') tempcelcius = float(data[1].split("'")[0]) csvdateformat = strftime('%Y%m%d %H:%M:%S %Z',pydate) csvdata.append([csvdateformat,tempcelcius])



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.