Page 1 of 1

read each line in from a file

Posted: Fri Dec 15, 2017 7:45 pm
by jmartin
read each line in a file

I am trying to read in each line in a generated file but having difficulty.
The file is created in the workspace via the Native Command, its just a 'ls -1' on a directory.

The results look like below in a file called ls1output.txt in the workspace.

I set my rowset variable to: ls1rowSet
and then do a foreach loop to print the lines.

which results in:
12/15/17 4:41:31 PM INFO Executing task 'readFlatFile 1.0'
12/15/17 4:41:31 PM INFO Data parsed successfully and the rowset variable 'ls1rowSet' was created
12/15/17 4:41:31 PM INFO Finished task 'readFlatFile 1.0'
12/15/17 4:41:31 PM INFO Entering loop 'forEachLoop'
12/15/17 4:41:31 PM INFO Opening file '/usr/local/Linoma_Software/GoAnywhere/userdata/workspace/1000000034569/ls1output.txt'
12/15/17 4:41:31 PM INFO Executing task 'print 1.0'
12/15/17 4:41:31 PM INFO [email protected]318ee04d

How can I read these lines in 1 by 1?

Any help is appreciated, tia.

<project name="Seat Vendor Transfers" mainModule="Main" version="2.0" logLevel="debug">
<description>Seat Vendor Testing upload to LAMP</description>

<module name="Main">

<createWorkspace version="1.0" />

<callModule label="Call: Native Cmd" module="Native Cmd" version="1.0" disabled="false" />
<callModule label="Call DirList" module="Create DirList" version="1.0" disabled="true" />
<callModule module="Files" version="1.0" />
<deleteWorkspace version="1.0" disabled="true" />

<module name="Native Cmd" description="runs ls -1 on dir, outputs to file">

<exec executable="ls" executableDir="/usr/bin/" workingDir="/usr/local/Linoma_Software/home/SVT" redirectOutputTo="file" outputFile="./ls1output.txt" outputFileVariable="ls1varout" version="1.0">
<arg value="-1" />
<arg value="/usr/local/Linoma_Software/home/SVT" />


<module name="Files">

<readFlatFile inputFile="./ls1output.txt" outputRowSetVariable="ls1rowSet" version="1.0" />

<forEachLoop itemsVariable="${ls1rowSet}" currentItemVariable="currItem">

<print version="1.0">


<module name="Create DirList">

<createFileList fileListVariable="dirList" version="1.0">
<fileset dir="${ls1varout}" />



Re: read each line in from a file

Posted: Wed Jan 03, 2018 12:03 pm
by Support_Josh
The issue that you are running into is a difference between what GoAnywhere MFT is expecting as a Record Delimiter and what the file actually is. If the file was created on a Linux OS, the EOL characters only consist of LF characters but MFT is set to look for CRLF to separate each record. Since the file doesn’t have those line endings, GoAnywhere MFT will read in the entire file as a single line.

To change that behavior, navigate to the Read Flat File task and open up the Advanced tab. Once opened up, you need to switch your Record Delimiter from CRLF to just LF. See screenshot below:
After making that change, your records should parse out separately and then should be able to create file lists as expected!