scripts: csv.py: Added bounded examples to -l/--list-fields
Now -l/--list-fields includes however many results fit in 36 chars: $ ./scripts/csv.py --list-fields test.csv i int # 16,17,14,18,19,15,20,13,12,29,27,28,... suite ? # bench_p26_wt case ? # bench_p26_wt_linear,bench_p26_wt_ran... NO_FRUNCATE int # 0 SIZE int # 2097152 SEED int # 42 The whole point of -l/--list-fields is to give a quick information dump about what's inside a csv file, and we're already parsing everything to try to figure out types, so why not? Much easier to read than head: $ head -n5 test.csv i,suite,case,NO_FRUNCATE,SIZE,SEED,BLOCK_SIZE,FILE_SIZE,SIM_... 16,bench_p26_wt,bench_p26_wt_linear,0,2097152,42,65536,64,36... 16,bench_p26_wt,bench_p26_wt_linear,0,2097152,42,65536,64,36... 16,bench_p26_wt,bench_p26_wt_linear,0,2097152,42,65536,64,36... 16,bench_p26_wt,bench_p26_wt_linear,0,2097152,42,65536,64,36...
This commit is contained in:
+23
-4
@@ -2423,13 +2423,32 @@ def list_fields(csv_paths, **args):
|
||||
else:
|
||||
types__.append('?')
|
||||
|
||||
# find widths
|
||||
w = [0]
|
||||
# show the first couple values for each field
|
||||
limit = 36
|
||||
examples__ = []
|
||||
for k in fields_:
|
||||
w[0] = max(w[0], len(k))
|
||||
x = co.OrderedDict()
|
||||
for r in results:
|
||||
if len(x) >= limit:
|
||||
break
|
||||
if k in r and r[k].strip():
|
||||
x[r[k].strip()] = True
|
||||
x = ','.join(x.keys())
|
||||
if len(x) > limit:
|
||||
x = x[:limit] + '...'
|
||||
examples__.append(x)
|
||||
|
||||
# find widths
|
||||
w = [0, 0]
|
||||
for k, t in zip(fields_, types__):
|
||||
print('%-*s %s' % (w[0], k, t))
|
||||
w[0] = max(w[0], len(k))
|
||||
w[1] = max(w[1], len(t))
|
||||
|
||||
for k, t, x in zip(fields_, types__, examples__):
|
||||
print('%-*s %-*s # %s' % (
|
||||
w[0], k,
|
||||
w[1], t,
|
||||
x))
|
||||
|
||||
def list_computed(fields_, results, Result, **args):
|
||||
# find best type for fields, note this matches compile behavior
|
||||
|
||||
Reference in New Issue
Block a user