mongoexport -d dataBase -c Info --csv -f title,type,time,price,new,place -o information.csv 2016-08-11T15:27:12.130+0800 csv flag is deprecated; please use --type=csv instead 2016-08-11T15:27:12.143+0800 connected to: localhost 2016-08-11T15:27:12.488+0800 exported 17438 records
client = MongoClient('localhost',27017) db = client['dataBase'] Info = db['Info'] analy = db['analy'] cnts = dict()
op = open('out.txt','w') for price in analy.find(): if price['price'] in cnts: cnts[price['price']] = cnts[price['price']]+1 else: cnts[price['price']] = 1
for item in cnts: print(item,cnts[item],file=op,sep='\t')
client = MongoClient('localhost',27017) db = client['dataBase'] Info = db['Info'] analy = db['analy'] cnts = dict() tot = dict() op = open('out.txt','w') for price in analy.find(): ps = int(price['price']) if ps < 3000:#选择精准数据 if ps in cnts: cnts[ps] = cnts[ps] + 1 tot[ps] = tot[ps] + price['inforNum'] else: cnts[ps] = 1 tot[ps] = price['inforNum']
for item in sorted(cnts): if cnts[item] > 1 : #clear special information print(item ,tot[item]/cnts[item],file=op,sep='\t') print(item , tot[item] / cnts[item], sep='\t')
client = MongoClient('localhost',27017) db = client['dataBase'] Info = db['Info'] analy = db['analy']
types = dict()
for month in range(1,13): cnts = dict() for data in analy.find(): if data['month'] == None: pass m = data['month'] + str('#') + str(data['inforNum']) if m in cnts: cnts[m] = cnts[m] + 1 else: cnts[m] = 1 months = sorted(cnts.keys()) print(months) for m in months: print('in month', m, 'info get', cnts[m]) ''' in month #2 info get 3 in month #3 info get 3 in month 01#2 info get 12 in month 01#3 info get 14 in month 02#2 info get 189 in month 02#3 info get 165 in month 02#4 info get 9 in month 03#2 info get 442 in month 03#3 info get 360 in month 03#4 info get 69 in month 04#2 info get 480 in month 04#3 info get 348 in month 04#4 info get 100 in month 05#2 info get 754 in month 05#3 info get 454 in month 05#4 info get 106 in month 06#2 info get 1206 in month 06#3 info get 724 in month 06#4 info get 247 in month 07#2 info get 992 in month 07#3 info get 1059 in month 07#4 info get 270 in month 08#2 info get 249 in month 08#3 info get 325 in month 08#4 info get 105 in month 09#2 info get 1 in month 09#3 info get 3 in month 10#3 info get 1 in month 11#2 info get 2 in month 11#3 info get 4 in month 12#2 info get 11 in month 12#3 info get 11 in month 12#4 info get 1 '''
client = MongoClient('localhost',27017) db = client['dataBase'] Info = db['Info'] analy = db['analy']
types = dict()
for month in range(1,13): cnts = dict() tot = dict() for data in analy.find(): if data['month'] == None: continue m = data['month'] if m in cnts: cnts[m] = cnts[m] + 1 tot[m] = tot[m] + data['inforNum'] else: cnts[m] = 1 tot[m] = data['inforNum'] months = sorted(cnts.keys()) #print(months) for m in months: print('in month', m, 'tot =',cnts[m],'\t','average info get',tot[m]/ cnts[m]) ''' in month tot = 6 average info get 2.5 in month 01 tot = 26 average info get 2.5384615384615383 in month 02 tot = 363 average info get 2.5041322314049586 in month 03 tot = 871 average info get 2.571756601607348 in month 04 tot = 928 average info get 2.5905172413793105 in month 05 tot = 1314 average info get 2.506849315068493 in month 06 tot = 2177 average info get 2.559485530546624 in month 07 tot = 2321 average info get 2.6889271865575184 in month 08 tot = 679 average info get 2.787923416789396 in month 09 tot = 4 average info get 2.75 in month 10 tot = 1 average info get 3.0 in month 11 tot = 6 average info get 2.6666666666666665 in month 12 tot = 23 average info get 2.5652173913043477 '''
client = MongoClient('localhost',27017) db = client['dataBase'] Info = db['Info'] analy = db['analy']
types = dict() tot = dict() op = open('out.txt','w')
for t in analy.find(): tp = t['type'] if tp in types: types[tp] = types[tp] + t['inforNum'] tot[tp] = tot[tp] + 1 else: types[tp] = t['inforNum'] tot[tp] = 1 i = 0 for type in types.keys(): if tot[type] == 1:continue i = i + 1 st = str(types[type]/tot[type])[0:3] if i % 5 == 0: print(type,'ave',st,file = op) else: print(type, 'ave', st, file=op,end='\t\t') if i > 100: break#only show some data