Deleting Data

Discussions about CSEntry
Post Reply
Ali
Posts: 11
Joined: June 6th, 2019, 4:43 am

Deleting Data

Post by Ali » November 1st, 2019, 4:34 am

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.

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

Re: Deleting Data

Post by josh » November 1st, 2019, 6:56 am

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);

Ali
Posts: 11
Joined: June 6th, 2019, 4:43 am

Re: Deleting Data

Post by Ali » November 1st, 2019, 7:39 am

Thanks Josh; solved! Thanks Again!

Gregory Martin
Posts: 1241
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Deleting Data

Post by Gregory Martin » November 3rd, 2019, 6:55 am

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.

Post Reply