Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions brewpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,14 +773,23 @@ def renameTempKey(key):
#write csv file too
csvFile = open(localCsvFileName, "a")
try:
lineToWrite = (time.strftime("%b %d %Y %H:%M:%S;") +
str(newRow['BeerTemp']) + ';' +
str(newRow['BeerSet']) + ';' +
str(newRow['BeerAnn']) + ';' +
str(newRow['FridgeTemp']) + ';' +
str(newRow['FridgeSet']) + ';' +
str(newRow['FridgeAnn']) + ';' +
str(newRow['State']) + ';' +
#is this a new csv file?
#opened with append so is at the end of the file. If tell returns 0 there is no data in the file (new file)
if csvFile.tell() == 0:
#add header
lineToWrite = 'DateTime,BeerTemp,BeerSet,BeerAnn,FridgeTemp,FridgeSet,FridgeAnn,State,RoomTemp\n'
csvFile.write(lineToWrite)
except KeyError, e:
logMessage("KeyError in line from controller: %s" % str(e))
try:
lineToWrite = (time.strftime("%b %d %Y %H:%M:%S,") +
str(newRow['BeerTemp']) + ',' +
str(newRow['BeerSet']) + ',' +
str(newRow['BeerAnn']) + ',' +
str(newRow['FridgeTemp']) + ',' +
str(newRow['FridgeSet']) + ',' +
str(newRow['FridgeAnn']) + ',' +
str(newRow['State']) + ',' +
str(newRow['RoomTemp']) + '\n')
csvFile.write(lineToWrite)
except KeyError, e:
Expand Down