I have the list that contains some items like:
"GFS01_06-13-2017 05-10-18-38.csv"
"Metadata_GFS01_06-13-2017 05-10-18-38.csv"
How to find the list item that start with "GFS01_"
In SQL I use query: select item from list where item like 'GFS01_%'
You have several options, but most obvious are:
Using list comprehension with a condition:
result = [i for i in some_list if i.startswith('GFS01_')]
Using filter
(which returns iterator)
result = filter(lambda x: x.startswith('GFS01_'), some_list)
You should try something like this :
[item for item in my_list if item.startswith('GFS01_')]
where "my_list" is your list of items.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With