Spaces:
Sleeping
Sleeping
File size: 946 Bytes
6c263e6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import json
# 将从hue中copy过来的fields转换为固定格式的字符串
def get_extract_fields(copy_str):
filed_arr = copy_str.split("\n")
with_comma = ""
no_comma = ""
with_comma_no_backspace = ""
special = ""
for k in range(len(filed_arr)):
fa = filed_arr[k]
field = fa.split(" ")[0]
no_comma += "%s\r\n" % field
with_comma += "%s,\r\n" % field
with_comma_no_backspace += "%s," % field
special += "coalesce(t2.%s,t1.%s) %s,\r\n" % (field, field, field)
return [no_comma, with_comma, with_comma_no_backspace, special]
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
# 直接复制json数据赋值json_str
filed_str = """fid (bigint)
fuserid (bigint)
froomid (bigint)
ftype (int)
fcount (int)
frecordtime (timestamp)
fcreatetime (timestamp)
fmodifytime (timestamp)
"""
print(get_extract_fields(filed_str)) |