You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/03/27 00:47:53 UTC

[iotdb] branch master updated: Make CSV Tool doc more readable (#2926)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new d2c1030  Make CSV Tool doc more readable (#2926)
d2c1030 is described below

commit d2c1030caf82b5f898420de855dc00f48b939cd9
Author: Steve Yurong Su <st...@outlook.com>
AuthorDate: Sat Mar 27 08:47:29 2021 +0800

    Make CSV Tool doc more readable (#2926)
---
 docs/UserGuide/System Tools/CSV Tool.md    | 98 ++++++++++++++++++++++++------
 docs/zh/UserGuide/System Tools/CSV Tool.md | 96 +++++++++++++++++++++++------
 2 files changed, 155 insertions(+), 39 deletions(-)

diff --git a/docs/UserGuide/System Tools/CSV Tool.md b/docs/UserGuide/System Tools/CSV Tool.md
index e3cacaa..e7c6f00 100644
--- a/docs/UserGuide/System Tools/CSV Tool.md	
+++ b/docs/UserGuide/System Tools/CSV Tool.md	
@@ -18,15 +18,17 @@
     under the License.
 
 -->
-# Csv tool
+# CSV Tool
+
+The CSV tool can help you import data in CSV format to IoTDB or export data from IoTDB to a CSV file.
+
 
-Csv tool is that you can import csv file into IoTDB or export csv file from IoTDB.
 
 ## Usage of import-csv.sh
 
 ### Create metadata (optional)
 
-```
+```sql
 SET STORAGE GROUP TO root.fit.d1;
 SET STORAGE GROUP TO root.fit.d2;
 SET STORAGE GROUP TO root.fit.p;
@@ -39,22 +41,21 @@ CREATE TIMESERIES root.fit.p.s1 WITH DATATYPE=INT32,ENCODING=RLE;
 
 IoTDB has the ability of type inference, so it is not necessary to create metadata before data import. However, we still recommend creating metadata before importing data using the CSV import tool, as this can avoid unnecessary type conversion errors.
 
-### An example of import csv file
 
-```
+
+### Sample CSV file to be imported
+
+```sql
 Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1
 1,100,hello,200,300,400
 2,500,world,600,700,800
 3,900,"hello, \"world\"",1000,1100,1200
 ```
-> Note that the following special characters in fields need to be checked before importing:
-> 1. `,` : fields containing `,` should be quoted by a pair of `"` or a pair of `'`.
-> 2. `"` : `"` in fields should be replaced by `\"` or fields should be enclosed by `'`.
-> 3. `'` : `'` in fields should be replaced by `\'` or fields should be enclosed by `"`.
-> 4. you can input time format like yyyy-MM-dd'T'HH:mm:ss, yyy-MM-dd HH:mm:ss, or yyyy-MM-dd'T'HH:mm:ss.SSSZ.
 
-### Run import shell
-```
+
+### Syntax
+
+```shell
 # Unix/OS X
 > tools/import-csv.sh -h <ip> -p <port> -u <username> -pw <password> -f <xxx.csv>
 
@@ -62,10 +63,35 @@ Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1
 > tools\import-csv.bat -h <ip> -p <port> -u <username> -pw <password> -f <xxx.csv>
 ```
 
-## Usage of export-csv.sh
 
-### Run export shell
+
+### Example
+
+```shell
+# Unix/OS X
+> tools/import-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -f example-filename.csv
+
+# Windows
+> tools\import-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -f example-filename.csv
 ```
+
+
+
+### Note
+
+Note that the following special characters in fields need to be checked before importing:
+
+1. `,` : fields containing `,` should be quoted by a pair of `"` or a pair of `'`.
+2. `"` : `"` in fields should be replaced by `\"` or fields should be enclosed by `'`.
+3. `'` : `'` in fields should be replaced by `\'` or fields should be enclosed by `"`.
+4. you can input time format like `yyyy-MM-dd'T'HH:mm:ss`, `yyy-MM-dd HH:mm:ss`, or `yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
+
+
+
+## Usage of export-csv.sh
+
+### Syntax
+```shell
 # Unix/OS X
 > tools/export-csv.sh -h <ip> -p <port> -u <username> -pw <password> -td <directory> [-tf <time-format> -s <sqlfile>]
 
@@ -73,14 +99,46 @@ Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1
 > tools\export-csv.bat -h <ip> -p <port> -u <username> -pw <password> -td <directory> [-tf <time-format> -s <sqlfile>]
 ```
 
-After running export shell, you need to input a data query, like `select * from root`. or specify a sql file. If you have multi sql in a sql file, sql should be split by new line character.
+After running the export script, you need to enter some queries or specify some SQL files. If there are multiple SQLs in one SQL file, the SQLs should be separated by line breaks.
 
-an example sql file:
 
-```
+
+### Sample SQL file
+
+```sql
 select * from root.fit.d1
 select * from root.sg1.d1
 ```
-> Note that if fields exported by the export tool have the following special characters:
-> 1. `,`: the field will be enclosed by `"`.
-> 2. `"`: the field will be enclosed by `"` and the original characters `"` in the field will be replaced by `\"`.
+
+
+### Example
+
+```shell
+# Unix/OS X
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./
+# Or
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss
+# Or
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s sql.txt
+# Or
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt
+
+# Windows
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./
+# Or
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss
+# Or
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s sql.txt
+# Or
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt
+```
+
+
+
+### Note
+
+Note that if fields exported by the export tool have the following special characters:
+
+1. `,`: the field will be enclosed by `"`.
+2. `"`: the field will be enclosed by `"` and the original characters `"` in the field will be replaced by `\"`.
+
diff --git a/docs/zh/UserGuide/System Tools/CSV Tool.md b/docs/zh/UserGuide/System Tools/CSV Tool.md
index d61d294..2b7d6ce 100644
--- a/docs/zh/UserGuide/System Tools/CSV Tool.md	
+++ b/docs/zh/UserGuide/System Tools/CSV Tool.md	
@@ -21,13 +21,15 @@
 
 # CSV 工具
 
-Csv工具是您可以导入csv文件到IoTDB或从IoTDB导出csv文件。
+CSV工具可帮您将CSV格式的数据导入到IoTDB或者将数据从IoTDB导出到CSV文件。
+
+
 
 ## 使用 import-csv.sh
 
 ### 创建元数据(可选)
 
-```
+```sql
 SET STORAGE GROUP TO root.fit.d1;
 SET STORAGE GROUP TO root.fit.d2;
 SET STORAGE GROUP TO root.fit.p;
@@ -39,23 +41,22 @@ CREATE TIMESERIES root.fit.p.s1 WITH DATATYPE=INT32,ENCODING=RLE;
 ```
 IoTDB具有类型推断的能力,因此在数据导入前创建元数据不是必须的。但我们仍然推荐在使用CSV导入工具导入数据前创建元数据,因为这可以避免不必要的类型转换错误。
 
-### 从 csv 文件导入数据的示例
 
-```
+
+### 待导入 CSV 文件示例
+
+```sql
 Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1
 1,100,hello,200,300,400
 2,500,world,600,700,800
 3,900,"hello, \"world\"",1000,1100,1200
 ```
 
-> 注意,在导入数据前,需要特殊处理下列的字符:
-> 1. `,` : 包含`,`的字段需要使用单引号或者双引号括起来
-> 2. `"` : "字段中的`"`需要被替换成转义字符`\"`或者用`\'`将字段括起来。
-> 3. `'` : "字段中的`'`需要被替换成转义字符`\'`或者用`\"`将字段括起来。
-> 4. 你可以输入时间格式像yyyy-MM-dd'T'HH:mm:ss, yyy-MM-dd HH:mm:ss, 或者yyyy-MM-dd'T'HH:mm:ss.SSSZ.
 
-### 运行 import shell
-```
+
+### 运行方法
+
+```shell
 # Unix/OS X
 > tools/import-csv.sh -h <ip> -p <port> -u <username> -pw <password> -f <xxx.csv>
 
@@ -63,11 +64,36 @@ Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1
 > tools\import-csv.bat -h <ip> -p <port> -u <username> -pw <password> -f <xxx.csv>
 ```
 
-## 使用 export-csv.sh
 
-### 运行 export shell
 
+### 运行示例
+
+```shell
+# Unix/OS X
+> tools/import-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -f example-filename.csv
+
+# Windows
+> tools\import-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -f example-filename.csv
 ```
+
+
+
+### 注意事项
+
+注意,在导入数据前,需要特殊处理下列的字符:
+
+1. `,` : 包含`,`的字段需要使用单引号或者双引号括起来
+2. `"` : "字段中的`"`需要被替换成转义字符`\"`或者用`\'`将字段括起来。
+3. `'` : "字段中的`'`需要被替换成转义字符`\'`或者用`\"`将字段括起来。
+4. 你可以输入时间格式像`yyyy-MM-dd'T'HH:mm:ss`, `yyy-MM-dd HH:mm:ss`, 或者`yyyy-MM-dd'T'HH:mm:ss.SSSZ`.
+
+
+
+## 使用 export-csv.sh
+
+### 运行方法
+
+```shell
 # Unix/OS X
 > tools/export-csv.sh -h <ip> -p <port> -u <username> -pw <password> -td <directory> [-tf <time-format> -s <sqlfile>]
 
@@ -75,15 +101,47 @@ Time,root.fit.d1.s1,root.fit.d1.s2,root.fit.d2.s1,root.fit.d2.s3,root.fit.p.s1
 > tools\export-csv.bat -h <ip> -p <port> -u <username> -pw <password> -td <directory> [-tf <time-format> -s <sqlfile>]
 ```
 
-在运行导出脚本之后,您需要输入一些查询或指定一些sql文件。如果在一个sql文件中有多个sql, sql应该被换行符分割。
+在运行导出脚本之后,您需要输入一些查询或指定一些SQL文件。如果在一个SQL文件中有多个SQL,SQL应该被换行符分割。
 
-一个sql文件例子
 
-```
+
+### SQL文件示例
+
+```sql
 select * from root.fit.d1
 select * from root.sg1.d1
 ```
 
-> 注意,如果导出字段存在如下特殊字符:
-> 1. `,` : 整个字段会被用`"`括起来。
-> 2. `"` : 整个字段会被用`"`括起来且`"`会被替换为`\"`。
\ No newline at end of file
+
+
+### 运行示例
+
+```shell
+# Unix/OS X
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./
+# Or
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss
+# Or
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s sql.txt
+# Or
+> tools/export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt
+
+# Windows
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./
+# Or
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss
+# Or
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s sql.txt
+# Or
+> tools/export-csv.bat -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -tf yyyy-MM-dd\ HH:mm:ss -s sql.txt
+```
+
+
+
+### 注意事项
+
+注意,如果导出字段存在如下特殊字符:
+
+1. `,` : 整个字段会被用`"`括起来。
+2. `"` : 整个字段会被用`"`括起来且`"`会被替换为`\"`。
+