46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# readFile v. 0.1
|
|
# - single instance timer
|
|
# - invio multiplo x send eventi accodati
|
|
#---------------------------------------------------------------
|
|
import os, sys
|
|
import argparse
|
|
#--------------------------------------------------------------
|
|
|
|
# gestione parser argomenti in input
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("inFile")
|
|
parser.add_argument("outFile")
|
|
args = parser.parse_args()
|
|
|
|
#with open('logfile.txt', 'r') as inf, open('persMem.dat',"w") as outf:
|
|
with open(args.inFile, 'r') as inf, open(args.outFile,"w") as outf:
|
|
data = inf.readlines()
|
|
|
|
lastDt = ""
|
|
lastMs = 0
|
|
stepMs = 200
|
|
|
|
for line in data:
|
|
words = line.split()
|
|
if words[2] == 'queue':
|
|
# recupero dataOra
|
|
newDt = words[0].replace("-","") + words[1].replace(":","")
|
|
|
|
# verifico se data/ora identica...
|
|
if (lastDt == newDt):
|
|
# --> aggiungo stepMs
|
|
lastMs += stepMs
|
|
else:
|
|
lastMs = 0
|
|
|
|
lastDt = newDt
|
|
|
|
newDt = newDt + '{:03d}'.format(lastMs) #str(lastMs)
|
|
#print words[0].replace("-","") + words[1].replace(":","") + " | " + newDt + "\n"
|
|
|
|
# print words
|
|
# outf.write(words[0].replace("-","") + words[1].replace(":","") + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n')
|
|
outf.write(newDt + '#' + words[4].replace(">","") + '#' + words[5].replace("[","").replace("]","") +'\n') |