# Python Code Works in Script Console but not Reports

**URL:** <https://forum.inductiveautomation.com/t/python-code-works-in-script-console-but-not-reports/107943>\
**Category:** General Discussion\
**Tags:** python\
**Created:** [June 30, 2025, 5:25pm UTC](https://forum.inductiveautomation.com/t/python-code-works-in-script-console-but-not-reports/107943 "2025-06-30T17:25:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kyle\_Young](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@Kyle\_Young](https://forum.inductiveautomation.com/u/Kyle_Young)\
**Post date:** [June 30, 2025, 5:25pm UTC](https://forum.inductiveautomation.com/t/python-code-works-in-script-console-but-not-reports/107943/1 "2025-06-30T17:25:13Z")

</div>

Has any one else had issues with code working in script console but fails when in an actual project. I am running this code below and it works in script console but fail when trying to generate a report. The part that is failing is checking if t\> 0. I posted a more complete segment below. Any ideas would be greatly appreciated. It consistently fails if row 0 Tons = 0 and row 1, 2, 3, 4, or 5 have a value \> 0.

```python

list1 = []
times = ['1 AM', '2 AM', '3 AM', '4 AM', '5 AM', '6 AM', '7 AM', '8 AM', '9 AM', '10 AM', '11 AM', '12 PM', '1 PM', '2 PM', '3 PM', '4 PM', '5 PM', '6 PM', '7 PM', '8 PM', '9 PM', '10 PM', '11 PM', '12 AM']
		
query = '''SELECT [Time],
				  [Slabs],
				  [Tons],
				  [Therms],
				  [Excluded_Tons]
		   FROM DowntimeReportSlabs'''
		   
ds= system.db.runPrepQuery(query, [], 'IgnitionDB')
t = 0
for row in range(ds.getRowCount()):
	#appends datasets to display 4 tables on the report
	
	
	if row <= 5:
		#time = ds.getValueAt(row, 'Time')
		time = times[row]
		s = ds.getValueAt(row, 'Slabs')
		t = ds.getValueAt(row, 'Tons')
		#if t == 0:
		#	t = .1
		therm = ds.getValueAt(row, 'Therms')
		if t > 0:
			th = therm/t
		else:
			th = 0
		list1.append([time, s, t, th])
		
		#list1.append([time, s, t])

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 30, 2025, 5:55pm UTC](https://forum.inductiveautomation.com/t/python-code-works-in-script-console-but-not-reports/107943/2 "2025-06-30T17:55:39Z")

</div>

The script console is Vision Scope, while reporting is Gateway Scope. Data types can vary. You should find an error in the gateway logs when this attempts to run in your report. Please show use the error (formatted as code).
