#! /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()