得到一个近1G的文本矩阵,想来个行列转换
刚开始很甜地觉得用个小包就能搞定
手头正在用numpy 于是来loadtxt
于是。。。卡了。。。本子果然是战斗力只有5的渣渣
接着随手写了个python脚本
想着不就是内存之类的不够用吗 我一行行地读不行吗!
def revefile(filename):
f=open(filename,'r')
# Although I plan to use numpy,but I found it's...too big...
os.mkdir('revetmp')
print 'begin read file...'
f=open('filname','r')
count=0
for s in f:
count+=1
s=s.replace('\t','\n').replace('\r','')
w=open('revetmp/t_'+str(count)+'.txt','wb+')
w.writelines(s)
w.close()
if(count%10000==0):print count
print count
f.close()
print 'try to paste files....'
os.system('paste -d\t revetmp/* > reversefile.txt')
os.system('rm -rf revetmp')
答案是 不行啊
280多万行 缓慢地爬了