From 84260ecff56ff608d7dc505951ec0bba6cb50486 Mon Sep 17 00:00:00 2001 From: Samuel Linclau Date: Wed, 21 Oct 2015 14:44:25 +0200 Subject: [PATCH] new feature: added new default columns naming method option --- lib/column-name.coffee | 17 +++++++++++------ lib/tablr.coffee | 6 +++++- package.json | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/column-name.coffee b/lib/column-name.coffee index 747df9a..b4403ef 100644 --- a/lib/column-name.coffee +++ b/lib/column-name.coffee @@ -1,11 +1,16 @@ module.exports = columnName = (index) -> - base = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' ') + if atom.config.get('tablr.defaultColumnNamingMethod') == 'numeric' + (1+index) + '' + else if atom.config.get('tablr.defaultColumnNamingMethod') == 'numericZeroBased' + index + '' + else + base = 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'.split(' ') - quotient = Math.floor(index / 26) + quotient = Math.floor(index / 26) - if quotient > 0 - columnName(quotient - 1) + base[index % 26] - else - base[index % 26] + if quotient > 0 + columnName(quotient - 1) + base[index % 26] + else + base[index % 26] diff --git a/lib/tablr.coffee b/lib/tablr.coffee index 69d49e6..b17ad3c 100644 --- a/lib/tablr.coffee +++ b/lib/tablr.coffee @@ -73,11 +73,15 @@ module.exports = type: 'boolean' default: true description: 'When copying from a table to paste the content in a text editor this setting will make each cell appear as if they were created from different selections.' - supportedCsvExtensions: type: 'array' default: ['csv', 'tsv'] description: 'The extensions for which the CSV opener will be used.' + defaultColumnNamingMethod: + type: 'string' + default: 'alphabetic' + enum: ['alphabetic', 'numeric', 'numericZeroBased'] + description: 'When file has no header, select the default naming method for the columns. `alphabetic` means use A, B,..., Z, AA, AB.. `numeric` is for simple numbers, ie 1,2.. `numericZeroBased` is similar as numeric, except that it starts numbering from 0 instead of 1' activate: ({csvConfig}) -> @csvConfig = new CSVConfig(csvConfig) diff --git a/package.json b/package.json index 93f2ebe..205c4ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tablr", "main": "./lib/tablr", - "version": "0.5.1", + "version": "0.5.2", "description": "Edit CSV files using a table editor", "repository": "https://github.com/abe33/atom-tablr", "license": "MIT",