Skip to Content
Author's profile photo Former Member

How to get number of rows count from file using BODS without loading the data.

Hi All,

I have created this document to show you how to get the no of rows count from file without loading it into table.

I have used BODS EXEC command to get the rows count in file.

My BODS is installed on Linux server.

———————————————–

Suppose I have file with name contract_master.csv .

In this file there are 10 columns and 100 rows.

Now if I want to get the count of rows in file then I have to write the following code in script:

$row_count = exec(‘/bin/sh’,’-c “wc -l /C:/Incoming_Files/contract_master.csv’,0);

print($row_count);

where row_count is the global variable of type varchar.

C:/Incoming_Files is path where file is kept.

Now when you run the job you will get the following output.

100 /C:/Incoming_Files/contract_master.csv

here first 100 represent total number of rows in file.

Now to remove the file path & file name use following code

$actual_count =  rtrim_blanks( ltrim_blanks( replace_substr(‘/C:/Incoming_Files/contract_master.csv’,”)));

I hope this will help you.

You can do testing vary easily using this functionality,let’s say you have 100 file in your project and you have to load all the files & post loading to varify the count whether all data loaded properly you can apply logic mentioned above.

Feel free to ask any doubt.

Thanks,

SB

Assigned tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dirk Venken
      Dirk Venken

      $actual_count = word($row_count,1);

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      oh thanks drik...

      I was not aware about it...

      Author's profile photo Former Member
      Former Member

      Hi Dirk,

      Any method of reading count from SAP ECC as source? while assigning values to variable using SQL or word for RDBMS and Flat file works need to know if there is something available for SAP Application as data store.
       

      Author's profile photo srinivas panala
      srinivas panala

      Hi Former Member,

      The above script

      $row_count = exec(‘/bin/sh’,’-c “wc -l /C:/Incoming_Files/contract_master.csv’,0);

      is not working for me its throwing some issue.
      my script is below:

      #$row_count =  exec(‘/bin/sh’,’-c "wc -l /C:Test_Folder/201612.csv’,0);

      Please look over the script and help me out.

      Thanks

      Author's profile photo Naveen vuppala
      Naveen vuppala

      How to do it in windows?