I am interested in copying the content of a file to a multidimensional List in Python.
The file goes like
b,30.83,0,u,g,w,v,1.25,t,t,01,f,g,00202,0,+
a,58.67,4.46,u,g,q,h,3.04,t,t,06,f,g,00043,560,+
a,24.50,0.5,u,g,q,h,1.5,t,f,0,f,g,00280,824,+
b,27.83,1.54,u,g,w,v,3.75,t,t,05,t,g,00100,3,+
b,20.17,5.625,u,g,w,v,1.71,t,f,0,f,s,00120,0,+
b,32.08,4,u,g,m,v,2.5,t,f,0,t,g,00360,0,+
What I want here is to separate the values with commas (','
) and newline ('\n'
, for jumping to the next dimension) ... for example:-
x[0][0]='b', x[0][1]=30.83, x[1][0]='a' ....
Is there some suggestions? I tried to use csv
, but it's too complicated for me to access the values later. Is there any way I could manage to do that with the simple file methods? Thanks in advance.