C/C++の宿題を片付けます 74代目
■ このスレッドは過去ログ倉庫に格納されています
0127デフォルトの名無しさん
2006/09/27(水) 02:54:57---- analyze.c ----
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
char buf[2048];
sprintf(buf, "cmd.exe /c C:\Python25\python.exe analyze.py %s", argv[1]);
return system(buf);
}
---- analyze.py ----
import os, os.path, sys, datetime
tagMacTable = {}
tempFileNames = set()
dirname = "RFIDTAG"
for line in file(sys.argv[1], "r"):
line = line.strip()
y, m, d, hh, mm, ss, tagid, mac, batflag, id = line.split(",")
fn = os.path.join(dirname, tagid + ".txt")
tempFileNames.add(fn)
print >> file(fn, "a"), line
tagMacTable.setdefault((tagid, mac), []).append(line)
for (tagid, mac), log in tagMacTable.items():
ts = []
for line in log:
y, m, d, hh, mm, ss, tagid, mac, batflag, id = line.split(",")
ts.append(datetime.datetime(*tuple(map(int, [y, m, d, hh, mm, ss]))))
if (max(ts) - min(ts)).seconds >= 5 or mac == "001047FB18CB":
for line in log: print >> file(os.path.join(dirname, tagid + mac + ".txt"), "w"), line
map(os.remove, tempFileNames)
■ このスレッドは過去ログ倉庫に格納されています