Hi All,
Is there any function which returns the number of records in flat-file? Any help is very much appreciated.
Thanks,
Naveen.
Counting the number of records.
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 1255
- Joined: Wed Feb 02, 2005 11:54 am
- Location: United States of America
Routine ...
Here is a sample routine that works with DS/Solaris/Unix
*************************************************************
** Routine: GetFileNbRows
** Creator: Youssef Loudiyi
** Company: BI Expertise - www.biexpertise.com
*************************************************************
**** Get the line count for .upd files in the Load folder
*Prepare and execute the count
UnixStmt = "wc -l ":FullFileName:" | awk '{print $1}' $1"
Call DSExecute('UNIX',UnixStmt,StdOut, ReturnValue)
*Check if the sentence "Cannot open" is found in the Standard Output, if so, there was no file in the folder.
IF INDEX(OConv(StdOut,"MCL"),"cannot open",1) THEN
Ans = 0
END
ELSE
IF ReturnValue = 0 then
Ans = Left(StdOut,Len(StdOut)-1)
END
ELSE
Call DSLogFatal("Error while trying to execute the 'wc -l' unix command on ":FullFileName, "IDWLineCounter")
END
END
*************************************************************
*************************************************************
** Routine: GetFileNbRows
** Creator: Youssef Loudiyi
** Company: BI Expertise - www.biexpertise.com
*************************************************************
**** Get the line count for .upd files in the Load folder
*Prepare and execute the count
UnixStmt = "wc -l ":FullFileName:" | awk '{print $1}' $1"
Call DSExecute('UNIX',UnixStmt,StdOut, ReturnValue)
*Check if the sentence "Cannot open" is found in the Standard Output, if so, there was no file in the folder.
IF INDEX(OConv(StdOut,"MCL"),"cannot open",1) THEN
Ans = 0
END
ELSE
IF ReturnValue = 0 then
Ans = Left(StdOut,Len(StdOut)-1)
END
ELSE
Call DSLogFatal("Error while trying to execute the 'wc -l' unix command on ":FullFileName, "IDWLineCounter")
END
END
*************************************************************
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: