5.31.3 READ

The READ command processes the nominated FILE and returns the information in a working list (unless the SVTABLE keyword is used).

To read a file from the local file system only requires the FILE keyword.

To read a file from a remote file system using the FTP protocol requires the HOST keyword with appropriate USER, PASSWORD and access details for the remote server.

The service also determines the encoding to apply to the read byte content to convert it to Unicode content and determines if the Unicode data needs to be archived.

Syntax:

Command

Keyword

Value

Developer notes

READ

FILE

value

Required. File path.

HOST

host:port

Conditional. Only required when reading from an FTP server.

USER

value

Conditional. Only required when reading from an FTP server.

PASSWORD

value

Conditional. Only required when reading from an FTP server.

NAMEFMT

0

Conditional. Only required when reading from an FTP server.

0 indicates an IBM i path name format library/file.member is to be used.

Note: no default value.

1

1 indicates a Windows path name format /directory/directory/file is to be used.

DATALINK

*PORT

Conditional. Only required when reading from an FTP server.

*PASV

Default.

MODE

*ASCII

Conditional. Only required when reading from an FTP server.

*BINARY

Default.

CONTENT

*CSV

Default. Read content as CSV data.

*TSV

Read content as TSV data.

*SV

Read content as separated by a value as specified in the SEPARATOR keyword.

SEPARATOR

 

Optional. See SEPARATOR.

ENCODING

 

Optional. See ENCODING.

SVROW

 

Optional. See SVROW.

SVROWLIMIT

 

Optional. See SVROWLIMIT.

SVMODE

 

Optional. See  SVMODE.

SVHEAD

 

Optional. See SVHEAD.

SVTABLE

 

Optional. See SVTABLE.

SVCOLUMN

 

Optional. See SVCOLUMN.

SVLABEL

 

Optional. See SVLABEL.

NUMBERFORMAT

 

Optional. See NUMBERFORMAT.

ARCHIVE

 

Optional. See ARCHIVE.

 

Example

READ FILE(/folder/file.csv) #WRKLST(field,field,field)

 

READ FILE(/folder/file.csv) SVHEAD(ORDER) #WRKLST(field,field,field)

 

READ FILE(/folder/file.csv) SVTABLE(TBLORDER) SVCOLUMN(TBLORDER) SVLABEL(23)