csvkit icon indicating copy to clipboard operation
csvkit copied to clipboard

Add option for the columns names if --no-header-row is used

Open hktonylee opened this issue 6 years ago • 2 comments

Currently if I use csvlook --no-header-row, it will generate alphabet sequence. However the sequence is generated in the way that it is super long for many columns. Let's say if the file have 500 columns. It will generate:

a, b, ..., y, z, aa, bb, cc, ... , yy, zz, aaa, bbb, ... , yyy, zzz, aaaa, bbbb, ...

In the last column, the column header will be like ggggggggggggggggggg. That is crazily long. And it is useless because I can't tell difference between ggggggggggggggggggg (500) and ggggggggggggggggg (474) easily.

Why not give the csvlook an option to choose from different naming methods? For example, we can provide more compact naming (just like Excel, a, b, ..., y, z, aa, ab, ac, ..., az, ba, ...). Or just simple plain number sequence (e.g. col1, col2, col3...). I would suggest to be --default-header-format=default, --default-header-format=excel and --default-header-format=number

hktonylee avatar Nov 27 '18 19:11 hktonylee

I created an upstream issue. If it's resolved, I can add the following option:

            self.argparser.add_argument('--default-header-format', dest='default_header_format', choices=['default', 'excel'],
                                        help='If --no-header-row is set, specify the default header format as "default" (a,b,c,...,aa,bb,cc,....) or "excel" (A,B,C,...,AA,AB,AC,...).')

jpmckinney avatar Jan 02 '19 20:01 jpmckinney

~~https://github.com/wireservice/agate/issues/724~~

jpmckinney avatar Jan 02 '19 20:01 jpmckinney