shell script to convert excel to

作者: 菩提老鹰 | 来源:发表于2015-12-29 19:57 被阅读191次

title: shell script to convert excel to json
date: 2015-05-15 11:24:01 +0800
comments: true
category: Linux
tags: linux

Requirement

    there are some excel files need to convert to Json format.
include Json level one and level two

    and for excel files, you need to refer to some example files from
https://github.com/opscolin/ShellScripts/tree/master/Excel2Json

Get script

wget https://github.com/opscolin/ShellScripts/blob/master/Excel2Json/Excel2Json.sh

Usage

bash Excel2Json.sh LevelOne.xlsx > LevelOne.txt
bash Excel2Json.sh 2 LevelTwo.xlsx > LevelTwo.txt

or you cat get usage by
[root@localtest /tmp ]# bash Excel2Json.sh
====================================================
Usage:
    #convert Level one
    Excel2Json.sh LevelOne.xlsx > LevelOne.txt
    #convert Level two
    Excel2Json.sh 2 LevelTwo.xlsx > LevelTwo.txt
====================================================

Example

## level one
[root@localtest liuchao]# bash Excel2Json.sh LevelOne.csv
[
    {
        "id":1,
        "name":"北京"
    },
    {
        "id":2,
        "name":"陕西"
    },
    {
        "id":3,
        "name":"河北"
    },
]

# level two

[root@localtest liuchao]# bash Excel2Json.sh 2 LevelTwo.csv
[
    {
        "id": 1,
        "name": "北京",
        "List": [
            {
                 "id": 1,
                 "name": "东城区"
            },
            {
                 "id": 2,
                 "name": "西城区"
            },
            {
                 "id": 3,
                 "name": "崇文区"
            },
            {
                 "id": 4,
                 "name": "宣武区"
            },
....

相关文章

网友评论

本文标题:shell script to convert excel to

本文链接:https://www.haomeiwen.com/subject/rdrihttx.html