Description
This tool counts the number of lines in a text file, with the option of only counting lines that contain a specified search string. This can be useful when dealing with large XML files for instance when you might wish to determine the number of features the XML file contains. It is also useful when used in conjunction with the file.readlines and file.extractlines tool when you are interested in viewing or extracting data from the end of a large text file.
The 'match' option requires that you specify a search string. If a line in the input file contains this string anywhere within that line it is included in the count. Note that the search string is interpreted literally, and does not interpret any characters as wildcards (e.g. *).
A number of tools have been developed to manipulate text files. They were developed to make it more efficient to import datasets delivered in text file format (e.g. weather datasets that are delivered as separate files for each year, or XML files containing spatial data), but are likely to be useful for a wide range of tasks. See the commands beginning with 'file' for further information.
Syntax
file.countlines(file, [match]);
| file | the full path to the input text file | |
| [match] | if specified counts the only the lines containing this string |
Example
file.countlines(file="C:\data\roads.gml");
file.countlines(file="C:\data\roads.gml", match="ENDOFRECORD");