From 65ce3e35c799cdaf2c27793ee2af52d1351a3491 Mon Sep 17 00:00:00 2001 From: bjjwwang Date: Tue, 7 Dec 2021 12:02:53 +0000 Subject: [PATCH] fix kv tools --- core/cube/cube-builder/tool/kv_to_seqfile.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/cube/cube-builder/tool/kv_to_seqfile.py b/core/cube/cube-builder/tool/kv_to_seqfile.py index 78295df8..1fc92655 100644 --- a/core/cube/cube-builder/tool/kv_to_seqfile.py +++ b/core/cube/cube-builder/tool/kv_to_seqfile.py @@ -54,13 +54,21 @@ def kv_to_seqfile(): finally: fp.close() for line in lines: - line_list = line.split(':') + line_list = line.split() + if len(line_list) < 1: + continue key = int(line_list[0]) - value = str(line_list[1]).replace('\n', '') + show = int(line_list[1]) + click = int(line_list[2]) + values = [float(x) for x in line_list[3:]] + + # str(line_list[1]).replace('\n', '') res.append(dict) key_bytes = struct.pack('Q', key) - row_bytes = struct.pack('%ss' % len(value), value) - print key, ':', value, '->', key_bytes, ':', row_bytes + row_bytes = "" + for v in values: + row_bytes += struct.pack('f', v) + print key, ':', values, '->', key_bytes, ':', row_bytes writer.write(key_bytes, row_bytes) f.close() write_donefile() -- GitLab