MMpy.File.get_field_id

Syntax

file.get_field_id(field_name)

Description

Returns the field ID for the given field name. The user should not make any assumptions on possible field ID values.

Parameters

Name
Type
Description

field_name 

str The name of the field to convert to its ID.

Returns

Type
Description
int The ID of the named field, or -1 if it doesn't exist or is invalid.

Notes

Record IDs are 1-based, meaning passing an index of 1 will return the first record.

Examples

file_path = MMpy.Project.path() + 'Collar.DAT'
field_name = 'EAST'

file = MMpy.File()
if not file.open(file_path):
    raise IOError('Error: problem opening file')

field_id = file.get_field_id(field_name)

Resource ID

IDPH_FILE_GET_FIELD_ID