line_lst.append(item["data"])
elif isinstance(item["data"], float):
line_lst.append("{:.1f}".format(item["data"]))
+ elif item["data"] is None:
+ line_lst.append("")
file_handler.write(",".join(line_lst) + "\n")
logging.info(" Generating the table {0} ...".
["value"]) / 1000000)
except (KeyError, TypeError):
# No data, ignore
- pass
+ continue
if data_lst:
tbl_item.append({"data": eval(operation)(data_lst)})
+ else:
+ tbl_item.append({"data": None})
elif cmd == "operation":
operation = args[0]
- nr1 = tbl_item[int(args[1])]["data"]
- nr2 = tbl_item[int(args[2])]["data"]
- if nr1 and nr2:
- tbl_item.append({"data": eval(operation)(nr1, nr2)})
- else:
+ try:
+ nr1 = float(tbl_item[int(args[1])]["data"])
+ nr2 = float(tbl_item[int(args[2])]["data"])
+ if nr1 and nr2:
+ tbl_item.append({"data": eval(operation)(nr1, nr2)})
+ else:
+ tbl_item.append({"data": None})
+ except (IndexError, ValueError, TypeError):
+ logging.error("No data for {0}".format(tbl_item[1]["data"]))
tbl_item.append({"data": None})
+ continue
else:
logging.error("Not supported command {0}. Skipping the table.".
format(cmd))
for item in tbl_lst:
if "ndr_top" in file_name \
and "ndr" in item[1]["data"] \
- and item[-1]["data"] >= 10:
+ and item[-1]["data"] >= 10.0:
_write_line_to_file(file_handler, item)
elif "pdr_top" in file_name \
and "pdr" in item[1]["data"] \
- and item[-1]["data"] >= 10:
+ and item[-1]["data"] >= 10.0:
_write_line_to_file(file_handler, item)
elif "ndr_low" in file_name \
and "ndr" in item[1]["data"] \
- and item[-1]["data"] < 10:
+ and item[-1]["data"] < 10.0:
_write_line_to_file(file_handler, item)
elif "pdr_low" in file_name \
and "pdr" in item[1]["data"] \
- and item[-1]["data"] < 10:
+ and item[-1]["data"] < 10.0:
_write_line_to_file(file_handler, item)
logging.info(" Done.")