'Adding Row from csv to an Array while applying a Filter

I have a snippet of a script that looks for highs and lows in a given csv column. I want to add an exempt list as a filtered-out condition.

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) 

In their current format, rowHigh and rowLow will filter out very specific exempt numbers. (i.e. not row ['MeterNo'] == "Random#1"). How can I apply the exempt list instead?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source