findall

C# FindAll VS Where Speed

大城市里の小女人 提交于 2019-12-28 05:56:04
问题 Anyone know any speed differences between Where and FindAll on List. I know Where is part of IEnumerable and FindAll is part of List, I'm just curious what's faster. 回答1: The FindAll method of the List<T> class actually constructs a new list object, and adds results to it. The Where extension method for IEnumerable<T> will simply iterate over an existing list and yield an enumeration of the matching results without creating or adding anything (other than the enumerator itself.) Given a small

findAll returning empty for html

我怕爱的太早我们不能终老 提交于 2019-12-25 11:54:07
问题 I'm using the BeautifulSoup module to parse an html file that I want to extract certain information from. Specifically game scores and team names. However, when I use the findAll function, it continually returns empty for a string that is certainly within the html. If someone can explain what I am doing wrong it will be greatly appreciated. See code below. import urllib import bs4 import re from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup my_url = 'http://www

Search for word (from list of words) in line (from list of lines) and append values to new list. Python

倖福魔咒の 提交于 2019-12-25 03:36:14
问题 If you had a list of names . . . query = ['link','zelda','saria','ganon','volvagia'] and a list of lines from a file data = ['>link is the first','OIGFHFH','AGIUUIIUFG','>peach is the second', 'AGFDA','AFGDSGGGH','>luigi is the third','SAGSGFFG','AFGDFGDFG', 'DSGSFGAAA','>ganon is the fourth','ADGGHHHHHH','>volvagia is the last', 'AFGDAAFGDA','ADFGAFD','ADFDFFDDFG','AHUUERR','>ness is another','ADFGGGGH', 'HHHDFDA'] how would you be able to look at all lines that start with '>' and then if

Using .format to use variable in regex findall object. Python

守給你的承諾、 提交于 2019-12-25 02:03:19
问题 I saw some examples of this here but it did not answer my question: Python Regular Expression findall with variable i'm trying to use a variable instead of the 9 but i can't seem to figure it out value = 9 ORF = re.findall(r'ATG(?:(?!TAA|TAG|TGA)…){ value ,}?(?:TAA|TAG|TGA)',seq) #obviously doesn't work or i wouldn't have made this post I tried: value = 9 ORF = re.findall(r'ATG(?:(?!TAA|TAG|TGA)…){ {} ,}?(?:TAA|TAG|TGA)'.format(value),seq) but got the error: ValueError: Single '}' encountered

CakePHP multiple JOIN findAll Conditions issue

為{幸葍}努か 提交于 2019-12-24 10:49:19
问题 Here is my complex (atleast i think it is complex) condition to find competitors from matches schedules and relating to events. Now I have HTBTM relations with events_competitors table, where multiple events have multiple competitors users entries. Here, I have used joins condition for joining and getting related events with competitors which works fine, but I also want to apply additional conditions, for is_black (check for black belt) and is_adult (check for adult person) 'EventCompetitor

Rails ActiveRecord: Is a combined :include and :conditions query possible?

天涯浪子 提交于 2019-12-23 09:31:35
问题 Imagine I have wiki Articles, with many Revisions. I'd like to do a query with ActiveRecord through the database, which only returns those Articles which have Revisions which are updated in the past 24 hours. Is such a thing possible? I'd imagine it'd be something like: Articles.find_all(:include => :revisions, :conditions => {:revision[updated_at] => 1.week.ago..Time.now.utc}) If this isn't possible, is there some type of raw SQL I could pass to find_by_SQL that'd do the trick? 回答1: If you

Yii query returning no results

假如想象 提交于 2019-12-23 02:19:19
问题 I'm struggling to create the correct query in Yii, I believe I'm making progress though. I need to check a related table and only want to return records that don't have a record in the related table. This was answered here- Yii determining existence of related models What is complicating this and I'm unsure how to overcome it, is that multiple users can have records in this related table. Therefore the full requirement is to return records where no related record exists, but only counting

Yii determining existence of related models

本小妞迷上赌 提交于 2019-12-23 01:40:11
问题 I want to run a findAll query that that only returns records where a related record doesn't exist. Can anyone tell me how this is done in Yii? Just a little bit of context in case it helps- I'm working on a survey application, the objects I'm working with are- QuestionSurvey AnsweredQuestion SurveyQuestion HAS_MANY AnsweredQuestion I therefore want to return QuestionSurvey models where no related AnsweredQuestion exists. Thanks in advance, Nick 回答1: If you SurveyQuestion::model()->with(

Python regex findall numbers and dots

▼魔方 西西 提交于 2019-12-20 23:35:06
问题 I'm using re.findall() to extract some version numbers from an HTML file: >>> import re >>> text = "<table><td><a href=\"url\">Test0.2.1.zip</a></td><td>Test0.2.1</td></table> Test0.2.1" >>> re.findall("Test([\.0-9]*)", text) ['0.2.1.', '0.2.1', '0.2.1'] but I would like to only get the ones that do not end in a dot. The filename might not always be .zip so I can't just stick .zip in the regex. I wanna end up with: ['0.2.1', '0.2.1'] Can anyone suggest a better regex to use? :) 回答1: re

Capturing named groups in regex with re.findall

随声附和 提交于 2019-12-19 03:39:15
问题 When I was trying to answer this question: regex to split %ages and values in python I noticed that I had to re-order the groups from the result of findall. For example: data = """34% passed 23% failed 46% deferred""" result = {key:value for value, key in re.findall('(\w+)%\s(\w+)', data)} print(result) >>> {'failed': '23', 'passed': '34', 'deferred': '46'} Here the result of the findall is: >>> re.findall('(\w+)%\s(\w+)', data) >>> [('34', 'passed'), ('23', 'failed'), ('46', 'deferred')] Is