我有一个像这样组织的表格(curves.csv)(没有组织会更好的描述)
CL,D,PD,CL,D,PD,CL,D,PD,CL,D,PD,CL,D,PD
A,1,a,B,1,b,C,1,c,D,1,d,E,1,e
A,2,f,B,3,g,C,2,h,D,4,i,E,2,j
A,5,k,B,6,l,C,5,m,D,8,n,E,5,o
我想将此表转换为
,A,B,C,D,E
1,a,b,c,d,e
2,f,,h,,j
3,,g,,,
4,,,,i,
5,k,,m,,o
6,,l,,,
8,,,,n,
我目前有这个:
celllines=["A","B","C","D","E"]
sorted_days=["1","2","3","4","5","8"]
for d in sorted_days:
curves=open("curves.csv","rU")
for line in curves:
line=line.rstrip().rsplit(",")
if line[0]!="CL":#removes header
for x in range(0,len(line),3):
if line[x] in celllines:
if line[x+1] == d:
print d,line[x],line[x+2]
else:
print d, line[x],""
curves.close()
我只是觉得我正在进一步形成答案,而不是更接近!一如既往,任何指针都会非常感谢