Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8581

Re: Need to validate a CSV file based on the first field of the last row

$
0
0

Hi Ramesh,

 

There are 3 ways as per my understanding -

 

1. In PI source structure define only one parameter to take each line of CSV under this parameter using     FCC like       -

    Structure -

        Record   0...unbound

              Text    0...unbound

 

    FCC - 

              Record.fieldName -  Text

              Record.fieldSeparator -  'nl'

              Record.endSeparator -   'nl'

 

   So in PI you will get value like -

 

   <Record>

     <Text>UserID,UserName,Closing Balance,.......</Text>

  </Record>

  <Record>

     <Text>DLTR0000333153,test.................... </Text>

  </Record>

  .

  .

  .

  .

  <Record>

     <Text>EOF,,,,................................. </Text>

  </Record>

 

 

Now take the whole thing in a UDF after removing context. Here, you can take the count of records and read the last one first. Split that depending on comma and store it in a array. Check first value of array - arr[0] . If its not EOF then through an exception else map it to the target structure taking multiple result List.

But here PI will pick each file to validate the condition.

 

2. Go for OS Script. As your source is SFTP so you need to take it first to an NFS location and then need to go for the command prompt solution . But here one pipeline will increase.

 

3. Some short on Custom Module can be written for that.

 

Thanks,

Apu


Viewing all articles
Browse latest Browse all 8581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>