interest.py 773 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 22 23 24 25 26 27
#! /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')
        tags = json.loads(fields[3])
        for tag in tags :
            interests = tag["tag"]
            for interest in interests:
                interestOne = interest["1"]
                interestTwo = ""
                if interestOne == "Games":
                    if "2" in interest :
                        interestTwo = interest['2']
                try:
                    print '\t'.join([fields[0],fields[1],interestOne.encode('utf-8'),interestTwo.encode('utf-8')])
                except ValueError,e:
                    continue

if __name__ == "__main__":
    main()