我有一段脚本,可以在给定的csv列中查找高点和低点。我想添加一个例外列表作为筛选出的条件。
arrayHigh = []
arrayLow = []
#creating an exempt list
#exempt = ['Random#1','Random#2']
with open(csvPath, 'rt') as f:
readerHigh = csv.DictReader(f)
rowHigh = [row for row in readerHigh if (row ['VoltageAMax'] > '259' and not row ['MeterNo'] == "Random#1")]
for row in rowHigh:
arrayHigh.append(row)
with open(csvPath, 'rt') as i:
readerLow = csv.DictReader(i)
rowLow = [row for row in readerLow if (row ['VoltageAMin'] < '228' and not row ['MeterNo'] == "Random#1")]
for row in rowLow:
arrayLow.append(row)
在其当前格式中,rowHigh和rowLow将过滤掉非常具体的免税数字。(即。
not row ['MeterNo'] == "Random#1"
)。我如何应用豁免列表?