four.py 452 Bytes
Newer Older
wang-jinfeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#! /usr/bin/python
# -*- coding:utf-8 -*- 

import sys, os
import re
import json

def main():
    for line in sys.stdin:
        line = line.strip()
        fields = line.split('\t')
        category_list = json.loads(fields[2])
        category = category_list[0]["name"]
        try:
            print '\t'.join([fields[0],fields[1],category.encode('utf-8')])
        except ValueError,e:
            continue

if __name__ == "__main__":
    main()