awk将普通文本转换成json文件
script1:
#!/bin/bash
#Date:--
#Author:eivll0m awk -F"\t" -vq='"' '{
a[$]=a[$]?a[$]"\t"$"\t"$"\t"$:$"\t"$"\t"$
}END{
for(i in a){
printf i"\t[";l=split(a[i],b,"\t");
for(j=;j<=l;j+=){
printf "{h_name"":"q b[j] q",";
printf "level"":"q b[j+] q",";
printf "addres"":"q b[j+] q"},"
}
print "]"
}
}' yy.txt|sed 's/,]$/]/' >>yy_json.txt
script2:
#!/bin/bash
#Date:--
#Author:eivll0m awk -F"\t" -vq='"' '
function json(x,y){printf("%s:%s,",q x q, q y q)}
function json2(x,y){printf("%s:%s",q x q, q y q)}
function json3(x,y){printf("%s:%s",q x q, y)}
{
printf "{";
json("id",$);
printf q"essential_info"q":{";
json("name",$);
json("introduction",$);
json("medical_insurance",$);
json("alias",$);
json("position",$);
json("infectivity",$);
json("route_of_transmission",$);
json2("multiple_population",$);
printf "},";
printf q"symptom"q":{";
json("typical",$);
json2("content",$);
printf "},";
json("pathogeny",$);
json("prevent",$);
printf q"inspect"q":{";
json("item",$);
json2("content",$);
printf "},";
json("differentiate",$);
printf q"treat"q":{";
json("mode",$);
json2("content",$);
printf "},";
json("nurse",$);
json("complication",$);
json3("hospital",$);
print "}"
}' jibin.TXT >jibin.json
awk将普通文本转换成json文件的更多相关文章
- 临时处理小记:把Numpy的narray二进制文件转换成json文件
临时处理一个Numpy的二进制文件,分析知道里面是dict类型,简单小记一下,如果Numpy和Python基础不熟悉可以看我之前写的文章 In [1]: %%time import numpy as ...
- 接口测试xml格式转换成json
未经允许,禁止转载!!!! 接口测试一般返回的是xml和json,现在大多数时候是返回成json的格式,但是有时候也会出现xml格式, 由于xml格式的文件阅读起来不是很容易懂,所以尽量将xml转换成 ...
- 将DataSet(DataTable)转换成JSON格式(生成JS文件存储)
public static string CreateJsonParameters(DataTable dt) { /**/ /**/ /**/ /* /*********************** ...
- json串转化成xml文件、xml文件转换成json串
1.json串转化成xml文件 p=[{"name":"tom","age":30,"sex":"男" ...
- 将Model对象转换成json文本或者json二进制文件
将Model对象转换成json文本或者json二进制文件 https://github.com/casatwy/AnyJson 注意:经过测试,不能够直接处理字典或者数组 主要源码的注释 AJTran ...
- C# Excel转换成Json工具(含源码)
可执行版本下载:https://github.com/neil3d/excel2json/releases 完整项目源代码下载:https://github.com/neil3d/excel2json ...
- Protocol Buffer使用转换工具将proto文件转换成Java文件流程及使用
Client与Server的网络通信协议传输使用google protobuf,服务器端使用的是Java 一. Protocol Buffersprotobuf全称Google Protocol Bu ...
- DataTable 转换成 Json的3种方法
在web开发中,我们可能会有这样的需求,为了便于前台的JS的处理,我们需要将查询出的数据源格式比如:List<T>.DataTable转换为Json格式.特别在使用Extjs框架的时候,A ...
- .NET(C#)中的DataSet、string、DataTable等对象转换成Json
ConvertJson.cs类 using System; using System.Collections.Generic; using System.Text; using System.Data ...
随机推荐
- UIAlertController基本使用
从ios8之后,系统的弹框 UIAlertView 与 UIActionSheet 两个并在一了起, 使用了一个新的控制器叫 UIAlertController UIAlertController ...
- javascript 获取url参数
/** window.location.search获取url地址?以后的值 获取url参数有两种方法,第一种如下,第二种是通过正则 */ //基本版 function getParam() { va ...
- (hdu)1950 Bridging signals(最长上升子序列)
Problem Description 'Oh no, they've done it again', cries the chief designer at the Waferland chip f ...
- itoa 和_itoa_s
1> itoa, 将整数转换为字符串. char * itoa ( int value, char * buffer, int radix ); 它包含三个参数: value, 是要转换的数字 ...
- STL unique使用问题
string strs[] = {"one","one","two","three","three" ...
- 九度OJ 1453 Greedy Tino -- 动态规划
题目地址:http://ac.jobdu.com/problem.php?pid=1453 题目描述: Tino wrote a long long story. BUT! in Chinese... ...
- 理解Java中的协变返回类型
在面向对象程序设计中,协变返回类型指的是子类中的成员函数的返回值类型不必严格等同于父类中被重写的成员函数的返回值类型,而可以是更 "狭窄" 的类型. Java 5.0添加了对协变返 ...
- python 自动化之路 day 07 面向对象基础
本节内容: 面向对象编程介绍 为什么要用面向对象进行开发? 面向对象的特性:封装.继承.多态 类.方法. 面向对象编程 OOP编程是利用"类"和"对象" ...
- git push后修改错误的commit message
Easiest solution (but please read this whole answer before doing this): git rebase -i <hash-of-co ...
- 系统重装后phpnow修复
最近在捣鼓wordpress,主题写了一半然后就重装了win8,在新系统里面访问127.0.0.1的时候出现无法访问的情况.主题写了一半,又不想重装wordpress导数据库这些繁琐的过程,于是,尝试 ...