How to Read Fortran Format Data in Python

Asked 1 years ago, Updated 1 years ago, 67 views

Ask how to load data in python.
The data to be read is in the format 10f8.3 in the format Fortran 80 column, as shown below.

0.01000.01000.0240.027-0.0260.020-0.119-0.154
  -0.015  -0.081  -0.045  -0.016  -0.163  -0.179  -0.128  -0.104  -0.091  -0.164
  -0.216  -0.159  -0.212  -0.290  -0.169  -0.267  -0.288  -0.203  -0.304  -0.348
  -0.259  -0.284  -0.356  -0.261  -0.294  -0.260  -0.229  -0.259  -0.174  -0.240
  -0.231  -0.194  -0.162  -0.253  -0.264  -0.216  -0.248  -0.168  -0.227  -0.265
.....

and 5000 pieces of data.

I'd like to read 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 in the column direction and put them in the array.
What should I do?
Do you like numpy?Should I use Pandas?
Thank you very much for letting me know.

python text-file pandas numpy

2022-09-30 21:17

1 Answers

d=[l[s:s+8]for sin range(0,len(l),8)]for lin open('g:\\data.txt').read().splitlines()]
list = [flatten for inner ind for flatten inner]
f_float=map(float,list)

I heard that you were able to get a one-dimensional list of float type in .


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.