Page 1 of 1

How do I append a file today and overwrite it tomorrow?

Posted: Fri Aug 03, 2012 11:38 am
by joycerecacho
Hi everybody.

I would like to have some tips about a case I have in my project.

I need to read a database daily, several times per day, and during the day I need to 'append' a file with these data and, when the day changes, the file must be overwritten and then start to 'append' it again.

PS. I can't create different files - one per day. The file must be the same: with the same name. We just overwrite it according to the date changing.

How can I make this control?

Thanks my friends.

Best regards,

Posted: Fri Aug 03, 2012 1:00 pm
by chulett
Sounds like you need a "pre-process" to delete the file when the day changes, then the job can simply overwrite each time.

Posted: Fri Aug 03, 2012 1:02 pm
by FranklinE
Hi Joyce.

What is behind the requirement that the file have the same name every day? My assumption for the rest of this post is that it is used by a subsequent job or process.

I have a similar situation in the other direction. I overwrite the same initial file every day, then have a process that makes a final edit to it, but the edited file has a unique name every day (current date in the file name).

I don't know if this will help, but one way to approach this:

Append to a uniquely named file each day. The current date is a handy way to do that. At the end of the day, copy it to the "must be the same name" file for further processing, and delete the current-date file when that is done.

Edit: Or what Craig suggested. :oops: