Spaces:
Sleeping
Sleeping
Download hive_copyfields_extract.py from upwds/quick-tools: direct link, hf CLI and curl.
- Browser
- Download file 946 Bytes
-
https://huggingface.co/spaces/upwds/quick-tools/resolve/main/hive_copyfields_extract.py
- Command line
-
hf download hf://spaces/upwds/quick-tools/hive_copyfields_extract.py
-
curl -L -o hive_copyfields_extract.py https://huggingface.co/spaces/upwds/quick-tools/resolve/main/hive_copyfields_extract.py
946 Bytes
| 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)) |