EXCEl自动化配置流程

本文详细描述了如何使用不同的技术读取Excel、CSV和数据库文件,进行表格管理(包括添加、删除和重命名),以及进行数据操作(如修改、增加行列)、数据分析(如分组、透视、函数计算)和数据关联。同时介绍了数据导出到Excel的不同格式选项。
摘要由CSDN通过智能技术生成

1. 读取表格

1.1. 读取excel

1.1.1. 读取一个sheet 一个表

{
    "action": "input",
    "type": "excel",
    "output_table": "表一",
    "args": {
        "file": "excelpath",
        "sheet": "涉及",
        "header": 1,
        "startrow": 0
    }
}

1.1.2. 一个sheet多个表

{
    "action": "input",
    "type": "excel",
    "output_table": "表一",
    "args": {
        "file": "excelpath",
        "sheet": "涉及",
        "tablename": "表名称",
        "header": 1,
        "startrow": 0
    }
}

1.2. 读取csv

{
    "action": "input",
    "type": "csv",
    "output_table": "表一",
    "args": {
        "file": "excelpath",
        "tablename": "表名称",
        "header": 1,
        "startrow": 0
    }
}

1.3. 读取数据库

{
    "action": "input",
    "type": "sqllie",
    "output_table": "表一",
    "args": {
        "file": "excelpath",
        "sql": "表名称"
    }
}

1.4. 读取 MYSQL

{
    "action": "input",
    "type": "mysql",
    "output_table": "表一",
    "args": {
        "ip": "excelpath",
        "usernane": "表名称",
        "password": "密码",
        "sql": "tabl"
    }
}

2. 表格处理-manage_table

参数

解释

add_table

remove_table

rename_table

copy_table

2.1. 增加表格

{
  "action": "manage",
  "type": "add_table",
  "newtable": "new_table"
}

2.2. 删除表格

{
    "action": "manage",
    "type": "remove_table",
    "tablename": "tablename"
}

2.3. 重命名表格

{
  "action": "manage",
  "type": "rename_table",
  "tablename": "tablename",
  "newtable": "newtable"
}

2.4. 复制表格

{
  "action": "manage",
  "type": "copy_table",
  "tablename": "tablename",
  "newtable": "newtable"
}

3. 增删改查

3.1. 修改表格

output_table 是新的表 列名称没有的话 会创建新的列

{
  "action": "crud",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "revise",
  "args": {
    "columns": [
      {"column": "列1","value": "表达式1"},
      {"column": "列2","value": "表达式2"}
    ]
  }
}

3.2. 增加新的行

在原来的out_table 上增加新的行 out_table 没有的时候会创建表格

{
    "action": "crud",
    "input_table": "input_table",
    "output_table": "output_table",
    "type": "add_rows",
    "args": {
        "columns": [
            {"column": "列1","value": "表达式1"},
            {"column": "列2","value": "表达式2"},
        ]
    }
}

3.3. 增加新的列

{
  "action": "crud",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "add_columns",
  "args": {
    "columns": [
      {"column": "列1","value": "表达式1"},
      {"column": "列2","value": "表达式2"},
    ]
  }
}

3.4. 删除列

{
  "action": "crud",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "del_columns",
  "args": {
    "columns": ["列1","列2"]
  }
}

3.5. 筛选表格

3.5.1. 行筛选

{
  "action": "crud",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "filter-row",
  "args": {
    "filter": "判断语句"
  }
}

3.5.2. 列筛选

固定列的筛选

{
  "action": "crud",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "filter-column",
  "args": {
    "items": ["column","column"]
  }
}

正则列筛选

{
  "action": "crud",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "filter-column",
  "args": {
    "regex": "正则语句"
  }
}

4. 数据分析--analysis

4.1. 数据分组

求和(sum)、平均值(mean)、计数(count)、最大值(max)、最小值(min)

{
    "action": "analysis",
    "input_table": "input_table",
    "output_table": "output_table",
    "type": "groupby",
    "args": {
        "group":"column1"
        "agg":{
            "column1": "sum",
            "column2": "count"
            }
    }
}

全部求和


{
    "action": "analysis",
    "input_table": "input_table",
    "output_table": "output_table",
    "type": "groupby",
    "args": {
        "group":"column1",
        "agg":"sum"
    }
}

4.2. 数据透视

{
  "action": "analysis",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "pivot",
  "args": {
        "index":"A",
        "columns":"B",
        "values":"C"
  }
}

{
  "action": "analysis",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "pivot",
  "args": {
        "index":"A",
        "columns":"B",
        "values":["C","D"]
  }
}

4.3. 数据堆叠与解堆叠

stack

4.4. 数据转置

T

4.5. 函数计算

求和(sum)、平均值(mean)、计数(count)、最大值(max)、最小值(min)

4.5.1. 行统计计算

regex 和 items 不能同时出现

{
  "action": "analysis",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "func",
  "args": {
    "axis":"row"
    "type": "sum",
    "items": ["column","column"],
    "regex": "正则语句",
    "new_column": "new_column",
  }
}

4.5.2. 列统计计算

regex 和 items 不能同时出现

{
  "action": "analysis",
  "input_table": "input_table",
  "output_table": "output_table",
  "type": "func",
  "args": {
    "axis":"column"
    "type": "sum",
    "items": ["column","column"],
    "regex": "正则语句",
  }
}

5. 数据关联

5.1. 左连接

{
    "action": "join",
    "left_table": "Left_table",
    "right_table": "right_table",
    "output_table": "output_table",
    "type": "left",
    "args": {
        "left":  ["column","column"],
        "right": ["column","column"]
    }
}

["sysname"]

5.2. 右连接

{
  "action": "join",
  "left_table": "Left_table",
  "right_table": "right_table",
  "output_table": "output_table",
  "type": "right",
  "args": {
    "left":  ["column","column"],
    "right": ["column","column"]
  }
}

5.3. 内连接

{
  "action": "join",
  "left_table": "Left_table",
  "right_table": "right_table",
  "output_table": "output_table",
  "type": "inner",
  "args": {
    "left":  ["column","column"],
    "right": ["column","column"]
  }
}

5.4. 全连接

{
    "action": "join",
    "left_table": "Left_table",
    "right_table": "right_table",
    "output_table": "output_table",
    "type": "outer",
    "args": {
        "left":  ["column","column"],
        "right": ["column","column"]
    }
}

6. 执行sql

output_table 没有的时候会创建新的表,有的时候会覆盖

{
    "action": "sql",
    "input_tables": ["tablename1","tablename2","tablename3"],
    "output_table": "表一",
    "sql": "sql语句"
}

7. 表格分裂

7.1. 分裂成行

{
    "action": "split",
    "type": "row",
    "input_table": "input_table",
    "output_table": "output_table",
    "args": {
        "column": "列1",
        "split": "_"
    }
}

7.2. 分裂到列

会生成新的表 当名称一样的是后覆盖

{
    "action": "split",
    "type": "column",
    "input_table": "in_table",
    "output_table": "out_table",
    "args": {
        "split": "_",
        "column": "列1",
        "newcolumns": [
            {"columname": "列1","num": 0},
            {"columname": "列2","num": 2}
        ]
    }
}

8. 写入表格

NEW-EXCEL-OTO
NEW-EXCEL-OTM
OLD-EXCEL-OTO
OLD-EXCEL-OTM

8.1. 写入新的EXCEL表

8.1.1. 一个sheet 一个表-NEW-EXCEL-OTO

{
  "action": "output",
  "type": "NEW-EXCEL-OTO",
  "file": "excelpath",
  "args": {
	  "sheetname1":{"tablename": "tablename1"},
	  "sheetname2":{"tablename": "tablename1"},
  }
}

8.1.2. 一个sheet 多个表-NEW-EXCEL-OTM

{
  "action": "output",
  "type": "NEW-EXCEL-OTM",
  "file": "excelpath",
  "args": {
	  "sheetname1":[{"tablename": "tablename1"},{"tablename": "tablename2"}],
	  "sheetname2":[{"tablename": "tablename1"},{"tablename": "tablename2"}]
  }
}

8.2. 写入现有的excel表

8.2.1. 一个sheet一个表 OLD-EXCEL

{
  "action": "output",
  "type": "OLD-EXCEL",
  "file": "excelpath",
  "args": {
        "sheetname1":[
            {"tablename": "tablename","start_line": 0}
        ],
	    "sheetname1":[
            {"tablename": "tablename","start_line": 0}
        ]
  }
}

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值