Description
This tool splits a text file into multiple, approximately equally sized, smaller text files. There are two optional arguments that make this a particularly useful command in certain situations. First, the 'hdr' option allows you to specify the number of lines that make up the header of the file that will also be written as the header of split files (thus preserving the header among all the files). For many data files this will just be 'hdr=1', but for some XML and GML file format the headers can occupy several dozen lines.
The second optional argument is 'match', which ensures a file is only split immediately following lines containing the match search string. In data files this will not normally be useful (because each line represents a different record and it does not matter where the break in lines occurs). But in XML or GML files a single record can occupy multiple lines, so it is important that breaks occur only at appropriate places.
If the output folder does not exist, the tool will attempt to create it. If any of the output files already exist, an error is generated and the tool stops.
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.split(file, folder, prefix, cnt, [hdr], [match]);
| file | the full path to the input text file | |
| folder | the output folder | |
| prefix | the file name prefix of the output files | |
| cnt | the number of output files to create (the input file is split between them) | |
| [hdr] | the number of header lines from the beginning of the file to include in each output file (default=0) | |
| [match] | breaks the file only on lines containing this string (default="") |
Example
file.split(file="C:\data\roads.gml", folder="C:\data\newroads", prefix="roads", cnt=5);
file.split(file="C:\data\roads.gml", folder="C:\data\newroads", prefix="roads", cnt=5, hdr=7, match="ENDOFRECORD");