Deleting multiple cases from CSDB file

Discussions about editing and cleaning data
Post Reply
msoni
Posts: 34
Joined: February 19th, 2024, 11:38 am

Deleting multiple cases from CSDB file

Post by msoni »

Hi and greetings

We are running a survey where around 45 devices being used for data collection and sending data on daily basis on CSWeb server. I download data everyday and process something and prepare data file for analysis.

There are 5 IDs which needs to be deleted as these were test cases.

I need to each time download and make excel output and then delete from the output excel. Is there a way to delete those 5 cases directly from CSDB file and after that, i export to excel.

I read documents which says using delcase function but says works only external dictionary.
Is there some other quick way of doing it within CSDB file ?

Thanks and Regards
Manoj
htuser
Posts: 658
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Deleting multiple cases from CSDB file

Post by htuser »

A few years ago Greg helped me with similar and a worse issue. It was the first and only batch application I ever wrote... :D
a) I created a list string with all the UUIDs of the cases I wanted to delete.
b) And wrote few logic lines in a batch application adding the main dictionary (and related csdb) as external dict.
Please take a look at the attached solutions.
DeleteCasesBatch.zip
(18.26 KiB) Downloaded 5332 times
Hope this help.
G.VOLNY, a CSProuser from Haiti, since 2004
msoni
Posts: 34
Joined: February 19th, 2024, 11:38 am

Re: Deleting multiple cases from CSDB file

Post by msoni »

Thanks. Will look into it.
Regards
msoni
Posts: 34
Joined: February 19th, 2024, 11:38 am

Re: Deleting multiple cases from CSDB file

Post by msoni »

Dictionary is missing in attached file.
Please send. Thanks
htuser wrote: January 29th, 2025, 12:29 pm A few years ago Greg helped me with similar and a worse issue. It was the first and only batch application I ever wrote... :D
a) I created a list string with all the UUIDs of the cases I wanted to delete.
b) And wrote few logic lines in a batch application adding the main dictionary (and related csdb) as external dict.
Please take a look at the attached solutions.
DeleteCasesBatch.zip

Hope this help.
htuser
Posts: 658
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Deleting multiple cases from CSDB file

Post by htuser »

You should replace case key or uuid, dictionary and item names with your own and test it.
G.VOLNY, a CSProuser from Haiti, since 2004
Gregory Martin
Posts: 1883
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Deleting multiple cases from CSDB file

Post by Gregory Martin »

@htuser's application uses the case UUID, which is necessary if you have multiple cases with the same key. If the case keys that you do not want are unique, you can use the key function to simply check against the list of bad cases and then skip them:
string case_key = key(DICT_NAME);

if case_key in "BAD_ID1", "BAD_ID2" then
    skip case
;
endif;
Post Reply