Page 1 of 1

How to count the rows in a rowset variable

Posted: Mon Mar 21, 2016 4:59 pm
by T_Bekker
We retrieve a file via SFTP, then read it with the Read CSV task. There is no output variable for the number of records read. Is there a way to determine the number of records in the rowset before proceeding? Currently when the file is empty (no rows), the read CSV task completes successfully, but the next step to insert the records into a database fails.

Re: How to count the rows in a rowset variable

Posted: Thu Apr 14, 2016 4:20 pm
by Support_Rick
Troy,

The quick answer is, there is no "reccount" var attached to the read CSV.

This is one quick way to check.

Do a "Search and Replace" in the file of the CRLF (or LF--depending on End of record marker). Replace it with the same thing.

For example:

<searchAndReplace inputFile="MyInboundFile.csv" outputDir="${system.job.workspace}" searchFor="${system.carriageReturn}${system.lineFeed}" replaceWith="${system.carriageReturn}${system.lineFeed}" numReplacementsVariable="NoRecs" version="1.0" />

When finished, you should have a variable called "NoRecs" that contains the number of Records (End of Record Markers) that was changed... which should give you the record count.

Hope this helps!