I'm switching from matlab to python.
The data I want to import is like this
4
6
2
1
2.0E8
0.2
0.002
1 2 6
2 3 4
2 4 5
2 5 6
0 0
1 0
2 0
2 1
1 1
0 1
4 0 -150
1 1 1
6 1 1
And this is how I read it in matlab
FP1=fopen('471220580.txt','rt');
NELEM=fscanf(FP1,'%d',1);
NPION=fscanf(FP1,'%d',1);
NVFIX=fscanf(FP1,'%d',1);
NFORCE=fscanf(FP1,'%d',1);
YOUNG=fscanf(FP1,'%e',1);
POISS=fscanf(FP1,'%f',1);
THICK =fscanf(FP1,'%f',1);
LNODS=fscanf(FP1,'%d',[3, NELEM])';
COORD=fscanf(FP1,'%f',[2,NPION])';
FORCE=fscanf(FP1,'%f',[3,NFORCE])';
FIXED=fscanf(FP1,'%d',[3,NVFIX])';
How can I import these data in python? I didn't find an equivalent for fscanf in python.
For What is the equivalent of Matlab 'fscanf' in Python?
numpy.loadtxt requires Each row in the text file must have the same number of values. This is not a good fit in my case.
numpy.loadtxtrequiresEach row in the text file must have the same number of values..