Page 1 of 1

Merging of 2 CSDBE Files

Posted: January 3rd, 2023, 12:38 am
by YFT_CBSD
Hello i'd like to ask if this screnario is possible:

A and B contatins the same CASE ID
A_CSDBE contains the data from section A-E
B_CSDBE contains the data section F

i want to merge the both files. is it possible?
Outcome will contain the data from Section A-F.
if yes. How?

Re: Merging of 2 CSDBE Files

Posted: January 3rd, 2023, 7:51 am
by Gregory Martin
This is traditionally done using a record sort: https://www.csprousers.org/help/CSSort/ ... _sort.html

However, record sorts only work on text files, so you could:

1) Convert both files to text.
2) Perform the record sort.
3) Convert the output data back to Encrypted CSPro DB (if necessary).

However, you will lose information that is not stored in a text file, like the sync history, so this may not necessarily be a viable option.

Anther option would be to:

1) Load B_CSDBE.
2) Store the Section F data in temporary variables.
3) Load A_CSDBE.
4) Copy the data from the temporary variables back to Section F.

Re: Merging of 2 CSDBE Files

Posted: January 3rd, 2023, 9:52 pm
by YFT_CBSD
Anther option would be to:

1) Load B_CSDBE.
2) Store the Section F data in temporary variables.
3) Load A_CSDBE.
4) Copy the data from the temporary variables back to Section F.

What tool will i use in this case?

Re: Merging of 2 CSDBE Files

Posted: January 4th, 2023, 6:28 am
by Gregory Martin
You would do this in a data entry or batch application. If this is all post-data collection processing, you could create a batch application:

1) The input dictionary to your program would be a dummy dictionary, meaning that you won't actually use it. You can create a new dictionary for this.

2) You will attach your actual dictionary to the program as an external dictionary.

Then your code would look something like this:
// load the case in B
setfile(MY_DICT, "b.csdbe");
loadcase(MY_DICT, "my_id");

// assign section F variables from B to temporary variables
numeric temp_f01 = F01;
numeric temp_f02 = F02;
// ...

// load the case in A
setfile(MY_DICT, "a.csdbe");
loadcase(MY_DICT, "my_id");

// assign temporary variables to A's section F
F01 = temp_f01;
F02 = temp_f02;

// save the case, either to A, or to a different file; this shows to a different file
setfile(MY_DICT, "new-file.csdbe|password=1234", append);
writecase(MY_DICT);

Re: Merging of 2 CSDBE Files

Posted: July 26th, 2023, 2:56 am
by YFT_CBSD
Hi, what function should i use in the

loadcase(HPQF2_DICT, "my_id");

to call all the caseid in my csdbe?
Thanks

Re: Merging of 2 CSDBE Files

Posted: July 27th, 2023, 8:27 am
by Gregory Martin
Can you clarify your question? Are you trying to look at all cases in your file? If so, you can iterate over every case using the forcase statement:

https://www.csprousers.org/help/CSPro/f ... ement.html

Re: Merging of 2 CSDBE Files

Posted: July 28th, 2023, 10:00 pm
by YFT_CBSD
Yes. for example I have 10cases in A.csdbe and 10 cases also in B.csdbe.
How can i set it at the loadcase function all at once(not manually typing all the case id of 10 cases).

Can u show how to insert the forcase function in the code below? Thanks
// load the case in B
setfile(MY_DICT, "b.csdbe");
loadcase(MY_DICT, "my_id");

// assign section F variables from B to temporary variables
numeric temp_f01 = F01;
numeric temp_f02 = F02;
// ...

// load the case in A
setfile(MY_DICT, "a.csdbe");
loadcase(MY_DICT, "my_id");

// assign temporary variables to A's section F
F01 = temp_f01;
F02 = temp_f02;

// save the case, either to A, or to a different file; this shows to a different file
setfile(MY_DICT, "new-file.csdbe|password=1234", append);
writecase(MY_DICT);

Re: Merging of 2 CSDBE Files

Posted: August 7th, 2023, 12:02 pm
by Gregory Martin
What I would do is put all the keys into a string list and then loop over them. For example, this will get all of A's IDs (assuming A is open at the beginning of this code), and then loop over each case:
    List string case_keys_in_a;
    keylist(MY_DICT, case_keys_in_a);
   
    do numeric ctr = 1 while ctr <= case_keys_in_a.length()
        setfile(MY_DICT, "a.csdbe");
        loadcase(MY_DICT, case_keys_in_a(ctr));
       
        //....
   
enddo;