Problem is that the data is being interpolated instead of discrete.

My solution is not working, which is trying to add zeroes to the hours that had zero events.
Return value is showing the query data like this:

Return data from my script is showing like this:

Script
#get a timestamp at the start of this hour
today=system.date.now()
start=system.date.getDate(1970,1,1)
dt=system.date.hoursBetween( start,today)
dt=system.date.addHours(start,dt)
#get timesstamps for each hour between 800 hours ago and now
eightHundredHours = [[system.date.addHours(system.date.addHours(dt,-800),x)] for x in range(800)]
#get all the dates that are in the query
datesInQuery=[]
for row in range(value.getRowCount()):
Hour = value.getValueAt(row, 'Hour')
datesInQuery.append([Hour])
#get all the hours in that 800, but not in the query
excludedHours=[x for x in eightHundredHours if x not in datesInQuery]
counter=0
valueHeaders = ['Hour', 'Events']
data = []
for x in range(800):
#set events to 0 if zero events during the hour
if [system.date.addHours(system.date.addHours(dt,-800),x)] in excludedHours:
data.append([system.date.addHours(system.date.addHours(dt,-800),x),0])
#get the value if there were events during the hour
if [system.date.addHours(system.date.addHours(dt,-800),x)] in datesInQuery:
Hour = value.getValueAt(counter, 'Hour')
Events = value.getValueAt(counter, 'Events')
data.append([Hour, Events])
counter=counter+1
data = system.dataset.toDataSet(valueHeaders, data)
return data
I added this to the bottom, and I think I started to find an issue in the script, but I am not sure how to fix it.
The excludedHours seem to be a list of lists with one value in them.
So I am comparing dates to objects.
edit: Had to edit the images as I had the first two columns order switched.
I am getting a different date format between the two of them?
Still doesn't work and I got them all to appear the same.
#get a timestamp at the start of this hour
today=system.date.now()
start=system.date.getDate(1970,1,1)
dt=system.date.hoursBetween( start,today)
dt=system.date.addHours(start,dt)
#get timesstamps for each hour between 800 hours ago and now
eightHundredHours = [system.date.addHours(system.date.addHours(dt,-800),x) for x in range(800)]
#get all the dates that are in the query
datesInQuery=[]
for row in range(value.getRowCount()):
Hour = value.getValueAt(row, 'Hour')
datesInQuery.append(Hour)
#get all the hours in that 800, but not in the query
excludedHours=[x for x in eightHundredHours if x not in datesInQuery]
counter=0
valueHeaders = ['Hour', 'Events']
data = []
for x in range(800):
#set events to 0 if there weren't events during the hour
if eightHundredHours[x] not in datesInQuery:
data.append([eightHundredHours[x],0])
#get the value if there were events during the hour
if eightHundredHours[x] in datesInQuery:
Hour = value.getValueAt(counter, 'Hour')
Events = value.getValueAt(counter, 'Events')
data.append([Hour, Events])
counter=counter+1
data = system.dataset.toDataSet(valueHeaders, data)
# tempheader= ['Datesinquery','generatedDates','excluded']
# testData=[]
# for row in range(value.getRowCount()):
# Hour=datesInQuery[row]
# genHour=eightHundredHours[row]
# excludedHour= excludedHours[row]
# testData.append([Hour,genHour,excludedHour ])
# data= system.dataset.toDataSet(tempheader, testData)
return data
Still the comparing is not working.
I even revised my code to get all the hours from math on the query hours.
#get all the hours that are in the query
hoursInQuery=[]
for row in range(value.getRowCount()):
Hour = value.getValueAt(row, 'Hour')
hoursInQuery.append(Hour)
#get generate hours before the hour at the end of the query
lastRow=value.getRowCount()-1
hoursToGen=671
generatedHours= [system.date.addHours(system.date.addHours( value.getValueAt(lastRow, 'Hour') ,-hoursToGen),x) for x in range(hoursToGen)]
#get the generated hours not in the query
exclusiveHours= [x for x in generatedHours if x not in hoursInQuery]
counter=0
valueHeaders = ['Hour', 'Events']
data = []
for x in range(hoursToGen):
#set events to 0 if there weren't events during the hour
if generatedHours[x] in exclusiveHours:
data.append([generatedHours[x],0])
#get the value if there were events during the hour
if generatedHours[x] not in exclusiveHours:
Hour = value.getValueAt(counter, 'Hour')
Events = value.getValueAt(counter, 'Events')
data.append([Hour, Events])
counter=counter+1
#data = system.dataset.toDataSet(valueHeaders, data)
tempheader= ['Datesinquery','generatedDates','excluded']
testData=[]
for row in range(value.getRowCount()):
Hour=hoursInQuery[row]
genHour=generatedHours[row]
excludedHour= exclusiveHours[row]
testData.append([Hour,genHour,excludedHour ])
data= system.dataset.toDataSet(tempheader, testData)
return data