pysys.utils.linecount¶
Counting the number of lines in a text file matching a specified regular expression.
linecount¶
- pysys.utils.linecount.linecount(file, regexpr=None, ignores=None, encoding=None, flags=0, **kwargs)[source]¶
- Count the number of lines in an input file matching a regular expression, return the count. - If the input regular expression is set to None, the method returns a count of the number of lines in the input file. The regular expression should be passed in as a string, i.e. - "[a-z]_foo.*"etc.- Parameters
- file – The full path to the input file 
- regexpr – The regular expression used for counting matches 
- ignores – A list of regular expressions that will cause lines to be excluded from the count 
- encoding – Specifies a non-default encoding to be used for opening the file. 
 
- Returns
- The number of matching lines in the input file 
- Return type
- integer 
- Raises
- FileNotFoundException – Raised if the input file does not exist