read each line in from a file
Posted: Fri Dec 15, 2017 7:45 pm
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.
svt-acro
svt-aeroman
svt-aim
svt-anz
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 com.linoma.ga.projects.tasks.converters.flatfile.FlatFileRowSet@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>
<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" />
</exec>
</module>
<module name="Files">
<readFlatFile inputFile="./ls1output.txt" outputRowSetVariable="ls1rowSet" version="1.0" />
<forEachLoop itemsVariable="${ls1rowSet}" currentItemVariable="currItem">
<print version="1.0">
<![CDATA[${currItem}]]>
</print>
</forEachLoop>
</module>
<module name="Create DirList">
<createFileList fileListVariable="dirList" version="1.0">
<fileset dir="${ls1varout}" />
</createFileList>
</module>
</project>
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.
svt-acro
svt-aeroman
svt-aim
svt-anz
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 com.linoma.ga.projects.tasks.converters.flatfile.FlatFileRowSet@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>
<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" />
</exec>
</module>
<module name="Files">
<readFlatFile inputFile="./ls1output.txt" outputRowSetVariable="ls1rowSet" version="1.0" />
<forEachLoop itemsVariable="${ls1rowSet}" currentItemVariable="currItem">
<print version="1.0">
<![CDATA[${currItem}]]>
</print>
</forEachLoop>
</module>
<module name="Create DirList">
<createFileList fileListVariable="dirList" version="1.0">
<fileset dir="${ls1varout}" />
</createFileList>
</module>
</project>