#!/usr/bin/env python
import numpy as np
from datetime import datetime
#fl = open('te.csv')
#item_id,item_geohash,item_category
fl = open('tianchi_mobile_recommend_train_user.csv')
#user_id,item_id,behavior_type,user_geohash,item_category,time
result = open('result.csv','w+')
tn = open('train.csv','w+')
ns = open('not.csv','w+')
format = "%Y-%m-%d"
#2014-11-20 09\n
#fl.close( )
#print text
#data = np.loadtxt(fl,dtype = str)
#X = data[:, 1:] # select columns 1 through end
#y = data[:, 0] # select column 0, the stock price
fl.readline()
for key in fl:
pt = key.split(',')
dt = pt[5].split(' ')
print dt[0]
ti = datetime.strptime(dt[0],format)
if ti>datetime(2014,12,1):
print pt
result.write(pt[2]+'\n')
tn.write(pt[0]+','+pt[1]+','+pt[3]+','+pt[4]+'\n')
ns.write(pt[0]+','+pt[1]+','+pt[2]+','+pt[3]+','+pt[4]+'\n')
# print key
fl.close()
tn.close()
result.close()
import numpy as np
from datetime import datetime
#fl = open('te.csv')
#item_id,item_geohash,item_category
fl = open('tianchi_mobile_recommend_train_user.csv')
#user_id,item_id,behavior_type,user_geohash,item_category,time
result = open('result.csv','w+')
tn = open('train.csv','w+')
ns = open('not.csv','w+')
format = "%Y-%m-%d"
#2014-11-20 09\n
#fl.close( )
#print text
#data = np.loadtxt(fl,dtype = str)
#X = data[:, 1:] # select columns 1 through end
#y = data[:, 0] # select column 0, the stock price
fl.readline()
for key in fl:
pt = key.split(',')
dt = pt[5].split(' ')
print dt[0]
ti = datetime.strptime(dt[0],format)
if ti>datetime(2014,12,1):
print pt
result.write(pt[2]+'\n')
tn.write(pt[0]+','+pt[1]+','+pt[3]+','+pt[4]+'\n')
ns.write(pt[0]+','+pt[1]+','+pt[2]+','+pt[3]+','+pt[4]+'\n')
# print key
fl.close()
tn.close()
result.close()