I'm attempting to run through a column in my Python data file and only want to keep the lines of data that have values of 5, 6, 7, 8, or 9 in a certain column.
var = [5, 6, 7, 8, 9]
import glob
import numpy as np
filname = glob.glob(''+fildir+'*')
for k in filname:
data = np.genfromtxt(k,skip_header=6,usecols=(2,3,4,5,8,9,10,11))
if data[:,1] not in var:
continue
"fildir" is just the directory where all of my files are at. data[:,1] have values that range from 1-15 and like I said, I just want to keep lines that have values 5-9. When I run this code I get:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Any helpful hints?