I'm quite new to Python and I have been trying to find a way to search a csv for a test string and return the index of that item in the csv. I am using the code below but find it hard to believe that there is not a function built in to the csv module to do this. I want to perform the 'lookup' so that I can select the column index, I will then do the same for another value and use the row index to get the data from the cell at the intersection of both indices. What I have at the moment returns for example '7' when printed.
with open('rooms.csv','r') as inf, open('roms_out.csv','w') as outf: reader = csv.reader(inf) writer = csv.writer(outf, quoting=csv.QUOTE_MINIMAL) for row in reader: m = [i for i, elem in enumerate(row) if MyApp.group_1 in elem] if m: print(str(m)+ str(reader.line_num))