Mercurial > hg > cc > cirrus_home
comparison bin/cdx2tsv.py @ 151:66d17f7410f2
fixed
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Tue, 26 Oct 2021 14:07:34 +0000 |
parents | a76cc0df2754 |
children | ace590c2fdfc |
comparison
equal
deleted
inserted
replaced
150:4e1364b8c89a | 151:66d17f7410f2 |
---|---|
29 | 29 |
30 fields=[((lambda x,y:(x,eval("lambda f:%s"%y)))(*(f[1:-1].split(',',maxsplit=1))) if f[0]=='(' else f) for f in fields] | 30 fields=[((lambda x,y:(x,eval("lambda f:%s"%y)))(*(f[1:-1].split(',',maxsplit=1))) if f[0]=='(' else f) for f in fields] |
31 for l in sys.stdin: | 31 for l in sys.stdin: |
32 (key,stamp,jj)=l.rstrip().split(' ',maxsplit=2) | 32 (key,stamp,jj)=l.rstrip().split(' ',maxsplit=2) |
33 ja=json.loads(jj) | 33 ja=json.loads(jj) |
34 #print(ja) | |
34 print('\t'.join((ja.get(f,'NA') if isinstance(f,str) else | 35 print('\t'.join((ja.get(f,'NA') if isinstance(f,str) else |
35 ((f[1](ja[f[0]]) if f[0] in ja else 'NA'))) for f in (ja.keys() if fields==["*"] else fields))) | 36 (f[1](ja[f[0]] if f[0] in ja else 'NA'))) for f in (ja.keys() if fields==["*"] else fields))) |
36 | 37 |