TEXREAD

Read text from text file


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Examples :: Related

Back to top

Description


Reads text from an input text file and writes it to a text segment in a PCIDSK imag file.
Back to top

Parameters


texread(file, texseg, texform, dbsn, dbsd, tfile, lasc)

Name Type Caption Length Value range
FILE * str Output file name 1 -    
TEXSEG List[int] Output text segment 0 - 1  
TEXFORM str Text format 0 - 4 ATT | FREE
Default: FREE
DBSN str Output segment name 0 -   Default: TEXREAD
DBSD str Output segment description 0 - 64  
TFILE * str Text file name 1 -    
LASC List[int] Last segment created 0 - 1  

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies name of the PCIDSK image file to receive the text segment.

TEXSEG

Specifies the text segment (type 140:TEX) to receive the input text. If this parameter is not specified, a new text segment is created.

TEXFORM

Specifies whether the text data should be checked for a valid attribute format. This is important if the text data will be used as attribute data by other programs.

Available options are:

If set to ATT, a warning is printed for each format error found in the text file. Text data is still read to the text segment, unchanged.

For more information about the the Attribute data format, see the Details section.

DBSN

Specifies a name (up to 8 characters) for the output text segment.

This parameter is required only if a new segment is created.

DBSD

Describes (in up to 64 characters) the contents or origins of the output data.

This parameter is used only if a new segment is created.

TFILE

Specifies the name of the text file from which text data is read.

LASC

This is an output parameter and requires no user input. If a new output segment is created, LASC is assigned the number for the new segment, after the function has finished executing.

Back to top

Details

TEXREAD reads text data from a specified text file (TFILE) to a text segment (TEXSEG) in a PCIDSK file (FILE). Text segments can be used to store free-form lines of text; for example, a text segment may contain descriptions and reports, or an EASI procedure to be used with imagery stored on the file. The most common use for text segments, however, is to store attribute data.

If the output text segment (TEXSEG) is not specified, a new segment is created using the specified name (DBSN) and description (DBSD). If the text segment is specified, DBSN and DBSD are ignored.

Text data can be checked to ensure that it conforms to the syntax of attribute data (TEXFORM="ATT"), or just read in directly as free-form text (TEXFORM="FREE").

Trailing blanks are removed, and leading blanks are retained.

Attribute data

Attribute data is made up of lines of text. Each line is either a comment or data. The components of an attribute text segment are described below.

Comment lines

COMMENT lines begin with a '!' (exclamation). There can be any number of comment lines and comment lines can appear anywhere. For example:

! This is a comment line

Data lines

DATA lines have the following three parts:
RANGE specifies the range of values associated with the attribute list. Attribute lines MUST be ordered with ascending ranges and ranges must not overlap. The following range forms are available:
Note: If specified, the special range form ':' must be the last line of attribute data in the text file.

ATTRIBUTE LIST is the list of attribute data associated with each range. It can consists of up to 64 numeric and/or character values separated by spaces. Although numeric and character values can be mixed in any order, the order -- once established -- must be maintained in the rest of the attribute lines. Each data line must have the same number of attributes.

Character attributes begin with a non-digit character or they are enclosed in quotes. Example attribute data lines are:

1     2     ABC     A     53.0 
0.1   3     '1AB'   C     1.0E25

Keep in mind that the appearance of the list of attributes (that is, their spacing) is determined by the spacing you assign when you create the text file.

The DESCRIPTION is optional free-form text at the end of a line of data which describes the attributes listed in the line. Descriptions are not required to be enclosed in quotes but must be separated from the list of attributes by a semicolon (;). Examples of free form descriptions are:

; data provided by USGS
; data N/A - value from previous year
; benchmark site
			

See the Examples section for an Attribute example.

Back to top

Examples

Simple text segment example

Read the EASI procedure COPPRM.EAS to a new text segment in the file 'local.pix'.The procedure file is read as free-form text.

from pci.texread import texread

file	=	"local.pix"
texseg	=	[]
texform	=	"FREE"
dbsn	=	"COPPRM"
dbsd	=	"EASI procedure COPPRM.EAS"
tfile	=	r"/pci/pro/COPPRM.EAS"
lasc	=	[]

texread( file, texseg, texform, dbsn, dbsd, tfile, lasc )
	

Attribute example

Read text file "attribute.txt" to a new text segment in the file 'local.pix'.

from pci.texread import texread

file	=	"local.pix"
texseg	=	[]
texform	=	"ATT"
dbsn	=	""
dbsd	=	"USGS Land use/Land cover Attributes"
tfile	=	"attribute.txt"
lasc	=	[]

texread( file, texseg, texform, dbsn, dbsd, tfile, lasc )

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.