Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Determine time interval for deletion
#1
Hi Gintaras, hi all

i'd like to store in a file data, beginning by a date.

Then, i'd like to iterate lines of the file, and delete line older than a defined interval, say 1 month (30 days).

example:

2016-05-02 13:40:21 "some data"

I got the idea from IStringMap example with DATE as key

Links or code to help?

Thanks
#2
Cannot use Sqlite database?

Then could execute "DELETE FROM table WHERE date<...".
#3
why, i can't see the connection between my question and your answer, would this involved genuine date management?
#4
Then could execute "DELETE FROM table WHERE date<...". Easier.
#5
ok, will look, but not sure it fits the bill..
#6
Macro Macro267
Code:
Copy      Help
out

str fileData=
;2016-05-02 13:40:21 "one"
;2016-10-02 13:40:21 "two"
;2016-08-02 13:40:21 "three"
;2016-10-12 13:40:21 "four"

DateTime d.FromComputerTime
d.AddParts(-30)
str sDate=d.ToStrFormat("{yyyy-MM-dd} {HH:mm:ss}")

str newData s
foreach s fileData
,if(strcmp(s sDate)<0) continue
,newData.addline(s)

out newData
#7
Perfexct, as usual, but i must look into sql one of these days, to replace eventually istringmaps routines.

Is sqlite faster than istringmap or icsv? if not, not relevant to switch, but worth knowing the information.
#8
In most cases slower.
#9
ok, will stick to istringmap then, no useless conversion .....


Forum Jump:


Users browsing this thread: 1 Guest(s)