Page 1 of 1

FileCopy Issue with Specific record type only

Posted: June 6th, 2021, 1:06 pm
by pradhanra01
Hi Gregory Martin,

Is there any way to copy the specific record type only while we execute filecopy command, for example I have data like below dicts..
col 1-1 Record Type
col 2-3 Enemurator's ID
col 4-15 Household ID

11921001011001
21921001011001
31921001011001
41921001011001
11921001011002
21921001011002
31921001011002
41921001011002
11921001011003
21921001011003
31921001011003
41921001011003

Now I need to copy data which contents only record type '1' to another file to check the status of allocations, Is it possible ??

Thanks & Regards,
Ramesh Pradhan

Re: FileCopy Issue with Specific record type only

Posted: June 7th, 2021, 8:46 am
by Gregory Martin
The filecopy function copies the entire file, so you can't include only some lines. If you're working with text files, you could do this with logic:
file input_file;
file output_file;
string line;

input_file.open(
"input filename.dat");
output_file.open(
"output filename.dat", create);

while input_file.read(line) do

    if
line[1:1] = "1" then
       
output_file.write(line);
   
endif;

enddo;

input_file.close();
output_file.close();

Re: FileCopy Issue with Specific record type only

Posted: June 9th, 2021, 6:27 am
by pradhanra01
Thank You Very Much Gregory Martin.