Skip to content

Commit

Permalink
Merge pull request #24 from Bugazelle/dev
Browse files Browse the repository at this point in the history
[Feat] Allow to use the wildcard * to match all the columns
  • Loading branch information
Bugazelle authored Feb 15, 2020
2 parents e48cfc9 + 72d6a46 commit cc8ee0e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,23 @@ You could use `export_csv_to_influx -h` to see the help guide.
-fsc, --force_string_columns, Force columns as string type, seperated as comma. Default: None
```

> **Note 1:** You could use the library programmablly.
> **Note:**
> 1. You could pass `*` to --field_columns to match all the fields: `--field_columns=*`, `--field_columns '*'`
> 2. CSV data won't insert into influx again if no update. Use to force insert: `--force_insert_even_csv_no_update=True`, `--force_insert_even_csv_no_update True`
```
from ExportCsvToInflux import ExporterObject
exporter = ExporterObject()
exporter.export_csv_to_influx(...)
```
## Programmatically

> **Note 2:** CSV data won't insert into influx again if no update. Use --force_insert_even_csv_no_update=True to force insert
Also, we could run the exporter programmatically.

```
from ExportCsvToInflux import ExporterObject
exporter = ExporterObject()
exporter.export_csv_to_influx(...)
# You could get the export_csv_to_influx parameter details by:
print(exporter.export_csv_to_influx.__doc__)
```

## Sample

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def readme():
with open('README.md') as f:
long_description = f.read()
index = long_description.find('```\n\n> **Note 1:**')
index = long_description.find('```\n\n> **Note:**')
long_description = long_description[:index]
long_description = long_description.replace('## Install', '**Install**')
long_description = long_description.replace('## Features', '**Features**')
Expand Down
2 changes: 1 addition & 1 deletion src/ExportCsvToInflux/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.21'
__version__ = '0.1.22'
4 changes: 3 additions & 1 deletion src/ExportCsvToInflux/exporter_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def __validate_columns(csv_headers, check_columns):
"""Private Function: validate_columns """

if check_columns:
if len(check_columns) == 1 and check_columns[0] == '*':
return csv_headers
validate_check_columns = all(check_column in csv_headers for check_column in check_columns)
if validate_check_columns is False:
print('Warning: Not all columns {0} in csv headers {1}. '
Expand Down Expand Up @@ -150,7 +152,7 @@ def export_csv_to_influx(self,
:param db_name: the influx db name
:param db_measurement: the measurement in a db
:param time_column: the time columns (default timestamp)
:param tag_columns: the tag columns
:param tag_columns: the tag columns (default None)
:param time_format: the time format (default %Y-%m-%d %H:%M:%S)
:param field_columns: the filed columns
:param delimiter: the csv delimiter (default comma)
Expand Down
23 changes: 15 additions & 8 deletions 中文说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,23 @@ pip install ExportCsvToInflux
-fsc, --force_string_columns, 强制将列的类型转换成string类型, 使用英文逗号 ',' 作为分隔符. 默认: None
```

> **注意点 1:** 可以使用代码调用
> **注意:**
> 1. --field_columns 可以使用通配符 `*`,来匹配所有的列: `--field_columns=*`, `--field_columns '*'`
> 2. 如果检查到csv文件没有更新, 数据不会重复插入到数据库. 可以使用强制插入: `--force_insert_even_csv_no_update=True`, `--force_insert_even_csv_no_update True`
```
from ExportCsvToInflux import ExporterObject
exporter = ExporterObject()
exporter.export_csv_to_influx(...)
```
## 使用代码调用

> **注意点 2:** 如果检查到csv文件没有更新, 数据不会重复插入到数据库. 可以使用 **--force_insert_even_csv_no_update=True** 强制插入
可以使用代码直接调用

```
from ExportCsvToInflux import ExporterObject
exporter = ExporterObject()
exporter.export_csv_to_influx(...)
# 更多关于export_csv_to_influx的参数细节:
print(exporter.export_csv_to_influx.__doc__)
```

## 示例

Expand Down

0 comments on commit cc8ee0e

Please sign in to comment.