From 4c31e368106acc73bcc12e0286dcbdb6bed4d29a Mon Sep 17 00:00:00 2001 From: Bugazelle Date: Fri, 14 Feb 2020 23:47:34 +0800 Subject: [PATCH] [Feat] --tag_columns not mandatory --- README.md | 2 +- src/ExportCsvToInflux/__version__.py | 2 +- src/ExportCsvToInflux/exporter_object.py | 12 ++++++------ ...4\270\255\346\226\207\350\257\264\346\230\216.md" | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 696cde9..d9bcabf 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ You could use `export_csv_to_influx -h` to see the help guide. -tf, --time_format, Timestamp format. Default: '%Y-%m-%d %H:%M:%S' e.g.: 1970-01-01 00:00:00. -tz, --time_zone, Timezone of supplied data. Default: UTC. -fc, --field_columns, List of csv columns to use as fields, separated by comma. **Mandatory** --tc, --tag_columns, List of csv columns to use as tags, separated by comma. **Mandatory** +-tc, --tag_columns, List of csv columns to use as tags, separated by comma. Default: None -b, --batch_size, Batch size when inserting data to influx. Default: 500. -lslc, --limit_string_length_columns, Limit string length column, separated by comma. Default: None. -ls, --limit_length, Limit length. Default: 20. diff --git a/src/ExportCsvToInflux/__version__.py b/src/ExportCsvToInflux/__version__.py index e160d93..dccb61c 100644 --- a/src/ExportCsvToInflux/__version__.py +++ b/src/ExportCsvToInflux/__version__.py @@ -1 +1 @@ -__version__ = '0.1.20' +__version__ = '0.1.21' diff --git a/src/ExportCsvToInflux/exporter_object.py b/src/ExportCsvToInflux/exporter_object.py index 179795a..a2769fa 100755 --- a/src/ExportCsvToInflux/exporter_object.py +++ b/src/ExportCsvToInflux/exporter_object.py @@ -117,8 +117,8 @@ def export_csv_to_influx(self, csv_file, db_name, db_measurement, - tag_columns, field_columns, + tag_columns=None, db_server_name='localhost:8086', db_user='admin', db_password='admin', @@ -266,9 +266,9 @@ def export_csv_to_influx(self, 'Please check the fields are in csv headers or not. Exporter stopping...') continue if not tag_columns: - print('Error: The input --tag_columns does not expected. ' - 'Please check the fields are in csv headers or not. Exporter stopping...') - continue + print('Warning: The input --tag_columns does not expected or leaves None. ' + 'Please check the fields are in csv headers or not. Continue checking...') + # continue match_columns = self.__validate_columns(csv_headers, match_columns) filter_columns = self.__validate_columns(csv_headers, filter_columns) @@ -496,8 +496,8 @@ def export_csv_to_influx(): help='Timezone of supplied data. Default: UTC') parser.add_argument('-fc', '--field_columns', required=True, help='List of csv columns to use as fields, separated by comma') - parser.add_argument('-tc', '--tag_columns', required=True, - help='List of csv columns to use as tags, separated by comma') + parser.add_argument('-tc', '--tag_columns', nargs='?', default=None, const=None, + help='List of csv columns to use as tags, separated by comma. Default: None') parser.add_argument('-b', '--batch_size', nargs='?', default=500, const=500, help='Batch size when inserting data to influx. Default: 500.') parser.add_argument('-lslc', '--limit_string_length_columns', nargs='?', default=None, const=None, diff --git "a/\344\270\255\346\226\207\350\257\264\346\230\216.md" "b/\344\270\255\346\226\207\350\257\264\346\230\216.md" index e7ebb13..f9f8d09 100644 --- "a/\344\270\255\346\226\207\350\257\264\346\230\216.md" +++ "b/\344\270\255\346\226\207\350\257\264\346\230\216.md" @@ -44,7 +44,7 @@ pip install ExportCsvToInflux -tf, --time_format, 时间戳格式. 默认: '%Y-%m-%d %H:%M:%S' 比如: 1970-01-01 00:00:00. -tz, --time_zone, 时区. 默认: UTC -fc, --field_columns, field列, 如果多列, 使用英文逗号 ',' 作为分隔符. **强制** --tc, --tag_columns, tag列, 如果多列, 使用英文逗号 ',' 作为分隔符. **强制** +-tc, --tag_columns, tag列, 如果多列, 使用英文逗号 ',' 作为分隔符, 默认: None -b, --batch_size, 批量插入数据库大小. 默认: 500 -lslc, --limit_string_length_columns, 设置某列或多列中数据的长度, 如果多列, 使用英文逗号 ',' 作为分隔符. 默认: None -ls, --limit_length, 长度大小. 默认: 20