Page 1 of 1

Deleting Data

Posted: November 1st, 2019, 4:34 am
by Ali
Hi;
I'm trying to delete/clear the data (.csdb ) before assigning other households in the data file. I mean I just want to remove/clear any previous data that exists before I put other households in this data file.
Many Thanks.

Re: Deleting Data

Posted: November 1st, 2019, 6:56 am
by josh
You can use the command delcase to remove a single case from a data file https://www.csprousers.org/help/CSPro/d ... ction.html

However if you want to delete all the cases in the file to empty the file it may be simpler to just delete the file using filedelete(). If you do this however, you should first close the file using the command close() and then reopen it again using setfile(). You can do that with logic like the following:
string nomFicherAffectations = filename(AFFECTATIONS_DICT);
close(AFFECTATIONS_DICT);
filedelete(nomFicherAffectations);
setfile(AFFECTATIONS_DICT, nomFicherAffectations, create);

Re: Deleting Data

Posted: November 1st, 2019, 7:39 am
by Ali
Thanks Josh; solved! Thanks Again!

Re: Deleting Data

Posted: November 3rd, 2019, 6:55 am
by Gregory Martin
And even easier way to do this is:
open(AFFECTATIONS_DICT, create);
The create flag removes all cases in the file, creating a brand new file.