Skip to content

Instantly share code, notes, and snippets.

@chengjun
Created July 23, 2014 07:03
Show Gist options
  • Select an option

  • Save chengjun/2104e4a2efdbd39bea40 to your computer and use it in GitHub Desktop.

Select an option

Save chengjun/2104e4a2efdbd39bea40 to your computer and use it in GitHub Desktop.
# !/user/bin/python
# coding: *-- utf-8 --*
from __future__ import division
import os,time,string,random
def network():
#select the content which has been shared more than 500 times
user = {}
fname = 'd:/renren/id2string.txt'
f = open(fname)
while True:
line = f.readline()
if len(line)==0:
break
tt = line.rstrip('\n')
tt = line.split('\t')
user[tt[1].rstrip('\n')]=tt[0]
#print str(user[len(user)-1])
f.close()
print "end read user translate"
fw = open('d:/renren/result/user_university.txt','w')
fname = 'd:/renren/university_info.txt'
f = open(fname)
flag = 0
while True:
line = f.readline()
if len(line)==0:
break
if flag==0:
flag=1
continue
else:
tt = line.rstrip('\n')
tt = line.split('\t')
#print str(tt[0])
if(tt[1].find('5Q')==-1):
if user.has_key(tt[0])==True:
fw.write(user[tt[0]]+'\t'+tt[1]+'\n')
f.close()
fw.close()
print "end translate"
if __name__ == "__main__":
network()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment