duplicate case ids message but no identical number ???

Discussions about CSEntry
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

duplicate case ids message but no identical number ???

Post by lls »

Dear CSPro users,

I am using a series of 7 external file (lookup) to bring data in my application. When running the application, I get an error message that it cannot create an index because of a duplicate case ids in one of the external file. The external file has 184 entries with a 7 digit number followed by text such as [1011001Protection and mixed solutions] 1=Region, 01=Country, 1001=the following text. There are no identical entries and no identical numbers across all entries. Why would CSPro generate a message about an duplicate case?

lls
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: duplicate case ids message but no identical number ???

Post by josh »

Try using the CSIndex tool from the tools menu to identify what CSPro thinks the duplicate is.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: duplicate case ids message but no identical number ???

Post by lls »

Yes, thank you. That is very useful.

This is the output, there was indeed a duplicate ids.


--------------------------------------------------------------------------------
Case ID: 108
------------
File: C:\Users\xxx\Desktop\Annex A\CSPro_BKP\Annex A v 2.104\LOOKUP DATA\
Duplicate record located in the file at line 8
1081001Protection and mixed solutions
------------
File: C:\Users\xxx\Desktop\Annex A\CSPro_BKP\Annex A v 2.104\LOOKUP DATA\
Duplicate record located in the file at line 50
1081004Advocacy for protection and solutions
--------------------------------------------------------------------------------
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: duplicate case ids message but no identical number ???

Post by lls »

As shown in the duplicate output in the message above, indexing is done from the first 3 digit, How can I use the 7 digit as a unique id?

I'm attaching the application, please advise.

lls
Attachments
Annex A v 2.104.zip
(202.69 KiB) Downloaded 345 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: duplicate case ids message but no identical number ???

Post by josh »

The indexing is done on whatever variables you put as ID items in the dictionary so just put the 7 digits under the ID items.
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: duplicate case ids message but no identical number ???

Post by lls »

Thank you josh for the advice. I tried this but then I will loose the cascade. I’m trying to set a cascade from Region down to Indicators. For that, I have 7 external dictionaries with .dat files that contains a set of lines that start with a number followed by text.

For example:

Country:
101Angola (1 being Africa and 01 being Angola)

PPG:
01101abcdef (01 being Angola and 101 being a PPG)

Goal:
1011001abcdef (101 being a PPG and 1001 being a Goal)

Etc.

The first set of numbers is used to define the next valueset. If the region is set to 1 then the Country field will have only entries starting with 1xx. If the country is set to 01 then the PPG field will have only entries starting with 01xxx etc.

So far this works well. My problem is that the first set of numbers is set as the ID number that must be unique. For example in 1011001 the ID number is 101 and not 1011001. In my external file (.dat) all numbers are unique if taken into account the whole (1011001 is unique) however, I may have 1011001 and 1011002 and as the ID is only 101 then I get a duplicate ids message.

My problem is that I can change the ID length but then I will lose the cascade and if I keep the cascade I have the duplicate ids issue. I am trying to find a way to keep the cascade as it is and to allow 1011001 and 1011002 or 1021001 and 1021002. I spent the day on this and I cannot find a solution as my coding skills are quite limited.

Here attached the latest application I am trying to make with its external dict and data files. Very grateful if someone could take the time to see if an easy solution can be found.

Thank you!!


******** IDs ********

Region:
1, 2, 3, 4, 5

Country:
01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, etc.

PPG:
101, 102, 103, 104, 105, etc.

Goal:
1001, 1002, 1003, 1004, etc.

Rights Group:
10001, 10002, 10003, 10004, etc.

Objective:
100001, 100003, 100003, 10004, etc.

Output:
1000001, 1000002, 1000003, 1000004, etc.

Indicator:
1011011001100011000011000001



********** Duplicate output ********
--------------------------------------------------------------------------------
Case ID: 113
------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\L
Duplicate record located in the file at line 13
1131001Protection and mixed solutions
------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\L
Duplicate record located in the file at line 80
1131005Emergency response
------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\L
Duplicate record located in the file at line 141
1131007Protection pending solutions
------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\L
Duplicate record located in the file at line 267
1131002Capacity building


--------------------------------------------------------------------------------
Case ID: 1006
-------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\LOOKUP DATA\List of Rights Group.dat
Duplicate record located in the file at line 22
100610001Basic Needs and Essential Services
100610003Durable Solutions
100610006Logistics and Operations Support
100610007Security from Violence and Exploitation
-------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\LOOKUP DATA\List of Rights Group.dat
Duplicate record located in the file at line 34
100610002Community Empowerment and Self Reliance
100610004Fair Protection Processes and Documentation
100610008Leadership, Coordination and Partnerships
-------------
File: C:\Users\laspadal\Desktop\Annex A\CSPro_BKP\Annex A v 2.104_Duplicate\LOOKUP DATA\List of Rights Group.dat
Duplicate record located in the file at line 42
100610005Favourable Protection Environment
--------------------------------------------------------------------------------
Attachments
Annex A v 2.104_Duplicate.zip
(203.45 KiB) Downloaded 328 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: duplicate case ids message but no identical number ???

Post by josh »

You need to include all previous levels in the hierarchy the lower levels of the hierarchy. So the ppg dictionary should have two id items: region and operation, the goal dictionary should have three id items: region, operation and ppg etc... This way you have unique ids in all the files. In loadcase you use the ids from all the lower levels e.g. loadcase(PPGS_DICT, REGION, OPERATION) or loadcase(GOALS_DICT, REGION, OPERATION, PPG).
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: duplicate case ids message but no identical number ???

Post by lls »

Thank you josh for the hint.

I understand the logic but I can't make it work.
The first step (region to operation) works fine but the second step (operation to PPG) doesn't.

This is OK --> Example: 101Angola

Code: Select all

PROC OPERATION

preproc

{Use lookup file to select operation as per region}

	REGIONS_LU10 = REGION;
		
	If !loadcase(REGION_TO_OPERATION_DICT,REGIONS_LU10) then
		errmsg("Invalid Region code %d, please reenter", REGIONS_LU10);
		reenter REGION;
	endif;

	do varying i = 1 until i > count(REGION_TO_OPERATION_DICT.REGION_TO_OPERATION_REC)
		
		operationCodes(i) = OPERATIONS_LU10(i);
		operationNames(i) = OPERATIONS_NAME_LU10(i);
	enddo;
	operationCodes(i) = notappl; 
	
{Call setvalueset using the arrays that contain operations codes and names }
	
	setvalueset($, operationCodes, operationNames);
	setcapturetype($,1);

This does not work --> Example: 101101PPGabc

Code: Select all

PROC PPG

preproc

{Use lookup file to select PPG as per operation}

	REGIONS_LU20 = REGION;
	OPERATIONS_LU20 = OPERATION;
		
	If !loadcase(OPERATION_TO_PPG_DICT,REGIONS_LU20,OPERATIONS_LU20) then
		errmsg("Invalid Operation code %d, please reenter", OPERATIONS_LU20);
		reenter OPERATION;
	endif;

	do varying i = 1 until i > count(OPERATION_TO_PPG_DICT.OPERATION_TO_PPG_REC)
		
		ppgCodes(i) = PPGS_LU20(i);
		ppgNames(i) = PPGS_NAME_LU20(i);
	enddo;
	operationCodes(i) = notappl; 
	
{Call setvalueset using the arrays that contain operations codes and names }
	
	setvalueset($, ppgCodes, ppgNames);
	setcapturetype($,1);
thanks,

lls
Attachments
CSPRo Annex A.zip
(192.32 KiB) Downloaded 344 times
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: duplicate case ids message but no identical number ???

Post by lls »

Sorry,

Now it works. Forgot to add the zero fill in dictionary
lls
Posts: 109
Joined: December 6th, 2011, 3:11 pm
Location: Geneva, Switzerland

Re: duplicate case ids message but no identical number ???

Post by lls »

From the code below, I can generate a dynamic valueset but how can I have the name of the selected item inserted in the next field which is an alpha field?

I tried something as simple as OPERATIONS_NAME(i) = OPERATIONS_NAME_LU10(i); but this doesn't work.

Code: Select all

PROC OPERATION

preproc

{Use lookup file to select operation as per region}

   REGIONS_LU10 = REGION;
      
   If !loadcase(REGION_TO_OPERATION_DICT,REGIONS_LU10) then
      errmsg("Invalid Region code %d, please reenter", REGIONS_LU10);
      reenter REGION;
   endif;

   do varying i = 1 until i > count(REGION_TO_OPERATION_DICT.REGION_TO_OPERATION_REC)
      
      operationCodes(i) = OPERATIONS_LU10(i);
      operationNames(i) = OPERATIONS_NAME_LU10(i);
   enddo;
   operationCodes(i) = notappl;
   
{Call setvalueset using the arrays that contain operations codes and names }
   
   setvalueset($, operationCodes, operationNames);
   setcapturetype($,1);
lls
Post Reply