shell script to convert excel to json shell腳本轉(zhuǎn)化excel文件到Json文件

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": "東城區(qū)"
            },
            {
                 "id": 2,
                 "name": "西城區(qū)"
            },
            {
                 "id": 3,
                 "name": "崇文區(qū)"
            },
            {
                 "id": 4,
                 "name": "宣武區(qū)"
            },
....
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容