0

I am reading cells in a table. Some cells have a specific string and some don't. How to separate cells with str from those w/o

I want to do this with python

29th Nov 2016, 2:10 PM
Dick
1 ответ
0
you may be able to do it using the 'in' keyword. assume you are using a loop to iterate through your table: yourstring = 'hello' for row in table: for i in row: if yourstring in row[i]: print('it contains my string) you will have to be careful if not all data is of a string type. you can either check the type first or catch it in an try statement. isinstance(row [I], str): if yourstring in row[i]: or try: if yourstring in row[i]: print('it contains my string) except Exception: print('not a string) can't remember the actual exception it will throw
21st Dec 2016, 5:39 AM
Elric Hindy
Elric Hindy - avatar