Commit ea92ae66 authored by Jean-Marie Favreau's avatar Jean-Marie Favreau
Browse files

Mise en forme et option nombre

parent 5542941f
......@@ -5,11 +5,13 @@
import argparse
from construct import *
import sys
from datetime import datetime
parser = argparse.ArgumentParser(description="Convert RM42 (UKK) binary log files to CSV format.")
parser.add_argument('input', metavar="INPUT", type=str, help='Input file (.dat format)')
parser.add_argument('output', metavar="OUTPUT", type=str, help='Output file (.csv format)')
parser.add_argument('-n', help="Store timestamp with a number", action='store_true')
args = parser.parse_args()
......@@ -25,6 +27,8 @@ print("Input:", input_file)
print("Output:", output_file)
number = args.n
encoding = Int16sl
......@@ -51,11 +55,15 @@ with open(input_file, 'rb') as f_input:
hour = binToHexUKK(result.hour)
minutes = binToHexUKK(result.minutes)
seconds = binToHexUKK(result.seconds)
if year != 2000 or month != 0 or day != 0 or hour != 0 or minutes != 0 or seconds != 0:
if (year != 2000 or month != 0 or day != 0 or hour != 0 or minutes != 0 or seconds != 0) and month <= 12 and month >= 1:
for entry in result.entries:
entry_csv = ';'.join([str(e) for e in entry])
print('{:02d}/{:02d}/{:04d} {:02d}:{:02d}:{:02d};{:s}'.format(day, month, year, hour, minutes, seconds, entry_csv), file=f_output)
if number:
nb = datetime(year, month, day, hour, minutes, seconds, 0).timestamp()
print('{:f};{:s}'.format(nb, entry_csv), file=f_output)
else:
print('{:02d}/{:02d}/{:04d} {:02d}:{:02d}:{:02d};{:s}'.format(day, month, year, hour, minutes, seconds, entry_csv), file=f_output)
else:
print("skip wrong entry")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment