From 85b7a48df71da6fd15104fd9c226ec8517b02a31 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 30 Jan 2026 00:46:49 -0600 Subject: [PATCH] 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... --- scripts/csv.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/scripts/csv.py b/scripts/csv.py index 51f15627..a4ae4c65 100755 --- a/scripts/csv.py +++ b/scripts/csv.py @@ -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