DATAX 从scv到csv 从csv到mysql

Posted Smartisan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DATAX 从scv到csv 从csv到mysql相关的知识,希望对你有一定的参考价值。

csv到csv

 1 {
 2     "setting": {},
 3     "job": {
 4         "setting": {
 5             "speed": {
 6                 "channel": 2
 7             }
 8         },
 9         "content": [
10             {
11                 "reader": {
12                     "name": "txtfilereader",
13                     "parameter": {
14                         "path": ["E:/DATAX/Workplace/TEXT/csv/catalogue.csv"],
15                         "encoding": "UTF-8",
16                         "column": [
17                             {
18                                 "index": 0,
19                                 "type": "string"
20                             },
21                             {
22                                 "index": 1,
23                                 "type": "string"
24                             }
25                         ],
26                         "fieldDelimiter": ",",
27                         "skipHeader": "False"
28                     }
29                 },
30                 "writer": {
31                     "name": "txtfilewriter",
32                     "parameter": {
33                         "path": "E:/DATAX/Workplace/TEXT/csv",
34                         "fileName": "in.csv",
35                         "writeMode": "truncate",
36                         "format": "yyyy-MM-dd",
37                         "header":[id, info]
38                     }
39                 }
40             }
41         ]
42     }
43 }

从csv到mysql

 1 {
 2     "job": {
 3         "setting": {
 4             "speed": {
 5                 "channel": 2
 6             }
 7         },
 8         "content": [
 9             {
10                "reader": {
11                     "name": "txtfilereader",
12                     "parameter": {
13                         "path": ["E:/DATAX/Workplace/TEXT/csv/catalogue.csv"],
14                         "encoding": "UTF-8",
15                         "column": [
16                             {
17                                 "index": 0,
18                                 "type": "string"
19                             },
20                             {
21                                 "index": 1,
22                                 "type": "string"
23                             }
24                         ],
25                         "fieldDelimiter": ",",
26                         "skipHeader": "False"
27                     }
28                 },
29                 
30                "writer": {
31 
32                     "name": "mysqlwriter",
33 
34                     "parameter": {
35 
36                         "writeMode": "insert",
37 
38                         "username": "root",
39 
40                         "password": "zb753951",
41 
42                         "column": [
43 
44                             "name",
45 
46                             "value"
47 
48                         ],
49 
50                         "session": [],
51 
52                         "connection": [
53 
54                             {
55 
56                                 "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/datax?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8",
57 
58                                 "table": ["csv1"]
59 
60                             }
61 
62                         ]
63 
64                     }
65 
66                 }
67                 
68                 
69             }
70         ]
71     }
72 }

 

以上是关于DATAX 从scv到csv 从csv到mysql的主要内容,如果未能解决你的问题,请参考以下文章

将 JSON 数据从 MySQL 表导出到 CSV

使用查询将数据从 EXCEL/CSV 加载到 MYSQL?

解决datax处理csv文件时总是提示脏数据问题

如何从 csv 文件中获取数据并使用 mysql 保存到 grails 中?

从命令行将 mysql 数据库转储到纯文本 (CSV) 备份

从 MySQL 导入到 Excel 的 CSV 在日期结束时留下“/”