Skip to main content
Solved

Arc script

  • January 10, 2025
  • 2 replies
  • 93 views

Forum|alt.badge.img

how to remove the first five lines in flat file using Arc script 

Best answer by Rohit

Hi @bala_bk,

 

You can use the fileReadLine operation in the Arc script to read the file line by line. By checking if the index value is greater than 5, you can then push the relevant data to the output.

Below is a sample script to remove the first 5 lines from a flat file:

 

<arc:set attr="file.file" value="[filePath]" />
<arc:set attr="output.data">
  <arc:call op="fileReadLine" in="file" out="line">
    <arc:if exp="[_index] > 5">[line.file:data]\n</arc:if>
  </arc:call>
</arc:set> 
<arc:push item="output" />

 

Please refer to our documentation on fileReadLine for more information: https://cdn.cdata.com/help/AZK/mft/op_FileReadLine.html

This topic has been closed for replies.

2 replies

Rohit
  • Employee
  • Answer
  • January 10, 2025

Hi @bala_bk,

 

You can use the fileReadLine operation in the Arc script to read the file line by line. By checking if the index value is greater than 5, you can then push the relevant data to the output.

Below is a sample script to remove the first 5 lines from a flat file:

 

<arc:set attr="file.file" value="[filePath]" />
<arc:set attr="output.data">
  <arc:call op="fileReadLine" in="file" out="line">
    <arc:if exp="[_index] > 5">[line.file:data]\n</arc:if>
  </arc:call>
</arc:set> 
<arc:push item="output" />

 

Please refer to our documentation on fileReadLine for more information: https://cdn.cdata.com/help/AZK/mft/op_FileReadLine.html


Forum|alt.badge.img
  • Author
  • Apprentice
  • January 10, 2025

How to remove the last line in flat file using Arc script ??

The below script is to add the “END” on the last line but I need to remove the END which is present in the last line of a Flat-file??

<arc:set attr="file.file" value="[filepath]" />

<arc:call op="fileRead" item="file">
  <arc:set attr="tmp.originalBody">[file.file:data]</arc:set>
</arc:call>

<arc:unset attr="output.data">[tmp.originalBody]END</arc:set>
<arc:unset attr="output.filename" value="940_[now()]" />
<arc:push item="output" />