match a specific string in excel and print those rows using python
Question: i am trying to print values from 4 columns in a excel. i need to match on a
particular string in the 4th column and then print only those rows which have
that string. (eg: if my 4th column in the 2nd row contains 'Sweet' i will
print the entire row)

sample excel:

    
    
    name; number; fruit;  comment
    test1 ;1   ;  apple ; healthy
    test2; 2;     banana ;sweet and healthy
    

here row2 should be printed

so far i have this , couldn't get to exact way to match string.

    
    
    import gzip
    import csv, io
    
    with gzip.open("/test.csv.gz", "r") as file:
          datareader = csv.reader(file)
    
          included_cols = [9, 10, 11]
          for row in datareader:
            content = list(row[i] for i in included_cols if row[i])
            print content
    


Answer: Making use of the fact that you are using a range (9 through 11):

    
    
    with gzip.open("/test.csv.gz", "r") as file: datareader = csv.reader(file)
        datareader = csv.reader(file)
        for row in datareader:
            if 'Sweet' in row[9:12]:
                print(row[9:12])
    

