Deleting Data

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Ali
Posts: 19
Joined: June 6th, 2019, 4:43 am

Deleting Data

Post 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.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Deleting Data

Post 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);
Ali
Posts: 19
Joined: June 6th, 2019, 4:43 am

Re: Deleting Data

Post by Ali »

Thanks Josh; solved! Thanks Again!
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Deleting Data

Post 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.
Post Reply