GME

Geospatial Modelling Environment

file.extractlines (Extract Lines From Text File)

Extracts a specified range of lines from a textfile and writes them to a new file

Description

This tool extracts a specified range of lines from a text file and writes them to a new file. It was designed to provide a way of inspecting text files (e.g. XML or GML files) that are so large they cannot be conveniently opened in other software. The user specifies a start and end line that defines the range of lines to extract. If the end line specified is larger than the number of lines in the file the tool will extract all lines from the specified start line to the end of the file. The file.countlines tool can be used to determine the total number of lines in the text file, which is useful if you wish to extract the last line in the file. This tool is also useful for determining if text data files have header lines (e.g. extract the first 10 lines).

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.extractlines(file, newfile, start, end);

filethe full path to the text file
newfilethe full path to the new text file to create
startthe line number to start reading from the input file
endthe line number to stop reading from the input file

Example

file.extractlines(file="C:\data\roads.gml", newfile="C:\data\roads.txt", start=100, end=250);


Messages

Please consider making a purchase to support the continued development of these tools  Read more...

Tips on how to use this interface efficiently  Read more...

Links

Open Source GIS

Copyright © 2001-2014 Hawthorne L. Beyer, Ph.D., Spatial Ecology LLC    Connect on LinkedIn