我有一个时间戳,如2015-08-31-21.43.47.986782,我需要获取此时间戳和当前系统时间戳之间捕获的所有数据。我该怎么做?我需要适应任何条件吗?如果是,请详细说明
答案 0 :(得分:0)
我会使用Python和正则表达式。如果您的数据格式为
TNotifyEvent
也就是说,如果每个日期之间有多行,那么您必须考虑每个日期的累计数据。以下代码
TMyThread = class(TThread)
private
FInterval: Integer;
FTerminateEvent: TEvent;
protected
procedure Execute; override;
procedure TerminatedSet; override;
public
OnEndJob: TNotifyEvent;
constructor Create(Interval: Cardinal; CreateSuspended: Boolean);
destructor Destroy; override;
end;
constructor TMyThread.Create(Interval: Cardinal; CreateSuspended: Boolean);
begin
inherited Create(CreateSuspended);
FInterval := Interval;
FTerminateEvent := TEvent.Create(nil, False, False, '');
end;
destructor TMyThread.Destroy;
begin
FTerminateEvent.Free;
inherited;
end;
procedure TMyThread.TerminatedSet;
begin
inherited;
FTerminateEvent.SetEvent;
end
procedure TMyThread.Execute;
begin
while not Terminated do begin
//do your stuff
//notify your connection to the main thread if you want
if Assigned(OnEndJob) then
Synchronize(procedure
begin
OnEndJob(Self);
end);
//wait fo some amount of time before continue the execution
if wrSignaled = FterminateEvent.WaitFor(FInterval) then
Break;
end;
end;
如果您读取的行没有日期,请在md [' msg2']词典中累积数据。因此,在循环中,您可以阅读系统时间,并检查md [' date']。如果相等,则可以在下次找到日期时中断。类似的东西:
2015-08-31-21.43.47.986782 zero data data the data some thing else and
some more data
one data data the data some thing else and some more data
two data data the data some thing else and some more data
three data data the data some thing else and some more data
four data data the data some thing else and some more data
2015-08-31-22.43.47.986782 zero this is some other datathis is some other datathis is some other data
one this is some other data
two this is some other data
three this is some other data
four this is some other data
five this is some other data
2015-08-31-23.43.47.986782 zero This data is completely new
one This data is completely new
two This data is completely new
three This data is completely new
不确定strftime格式,但不是这样的。根据您是否需要之前或之后的日志,您可以将其放在if myMatch:或者其他:
中