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
FileCopy Issue with Specific record type only
-
- Posts: 38
- Joined: August 27th, 2017, 2:43 am
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: FileCopy Issue with Specific record type only
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();
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();
-
- Posts: 38
- Joined: August 27th, 2017, 2:43 am
Re: FileCopy Issue with Specific record type only
Thank You Very Much Gregory Martin.