DataMiningCompetitionFirstPrize
DataMiningCompetitionFirstPrize copied to clipboard
temps 究竟是什么?
lines = open(root_loc).readlines() for line in lines[:500]: temps = line.strip("\n").split("$") temps 读取出来的格式是 ['1006,"POS消费","地点551","淋浴","2013/09/01 00:00:32","0.5","124.9"']
'stuId':int(temps[0]) 不太对!
for i in range(1, len(temps)): records = temps[i].split(",")
len(temps) 就为1 感觉不太对
如果第一步line 换成逗号分隔符(原始数据的分隔符是逗号) for line in lines[:500]: temps = line.strip("\n").split(",")
temps 读取出来的格式是 ['1006', '"POS消费"', '"地点551"', '"淋浴"', '"2013/09/01 00:00:32"', '"0.5"', '"124.9"']
for i in range(1, len(temps)): records = temps[i].split(",") cate = records[0].strip(""") location = records[1].strip(""")[2:] .....
一条记录遍历 6次 感觉也不太对。 看代码的意思是想把一条用户对应的多条消费记录取出来,然后在多条记录里面进行循环汇总, 不知道我有没有理解错?还是code有点小问题,中间少了步骤吗?Python菜鸟,求大神解释,先谢啦!
README中的 $ python createStudentForms.py borrow_final_test $ ... 会把所有表中同一个学号的信息汇总到一起。