Python: searching csv and return entire row
#!/usr/bin/python
import csv
import sys
#input number you want to search
number = raw_input('Enter number to find\n')
#read csv, and split on "," the line
csv_file = csv.reader(open('test.csv', "r"), delimiter=",")
#loop through the csv list
for row in csv_file:
#if current rows 2nd value is equal to input, print that row
if number == row[1]:
print (row)
you can use csv
module like this:
import csv
reader = csv.reader(open(csvFile, 'r'))
for data in reader:
#list index start from 0, thus 2938 is in data[1]
if data[1] == agv_O_Cal.value and data[3] == agv_O_Mod.value:
#do somethinngs