You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
1.1 KiB

import json, os
base = r'.scratch/opportunity-e2e/env-raw'
out_path = r'.scratch/opportunity-e2e/env-analysis3.txt'
_buf = []
def out(s=''):
_buf.append(str(s))
with open(os.path.join(base, 'dict-items.json'), encoding='utf-8-sig') as f:
items = json.load(f)
def fix(s):
if not isinstance(s, str):
return s
try:
return s.encode('latin-1').decode('utf-8')
except (UnicodeEncodeError, UnicodeDecodeError):
return s
out('=== DICT ITEMS per group ===')
for grp, lst in items.items():
out('--- %s: %s items ---' % (grp, len(lst) if isinstance(lst, list) else 'null'))
def dump_group(grp, maxn=30):
lst = items.get(grp) or []
out('=== %s ===' % grp)
for it in lst[:maxn]:
out('code=%s name=%s parent=%s level=%s' % (
it.get('code'), fix(it.get('name')), it.get('parentId'), it.get('level')))
for grp in ['industry', 'opp_stage', 'opp_source', 'pool_reason', 'pause_reason', 'close_reason', 'survey_seq', 'follow_way', 'result_tag']:
dump_group(grp)
with open(out_path, 'w', encoding='utf-8') as f:
f.write('\n'.join(_buf))
print('written', out_path, len(_buf), 'lines')