Create exception for PartType and Orders < 50

I want to create a filterList for exception parts to not be sent to the excel file. I also want to exclude count of orders over 50. I know I can filter orders within the SQL Query but I want to do it within the script. Any help is appreciated!

import datetime    	    
currDate =

data = system.db.runNamedQuery('ODS/yardenTest/ordersAvailable')

filterList = ['']
dataNew = [ ]

for row in data:
	if row['PartType'] in filterList:

file = system.dataset.toExcel(True,[dataNew])
filePath = "C:\\Users\\YardenLevy\\Documents\\LowProductionOrders" +, "MM-dd-yy") + ".xlsx"
system.file.writeFile(filePath, file)

Regular datasets (returned by named queries) are not iterable. Convert to a PyDataset before your loop.

Yep, I figured out my mistake and got it sorted. I created a new dataset and appended the data from the named query into it, then iterated the list.