回答編集履歴

1

コメントへの回答

2021/10/26 14:53

投稿

ppaul
ppaul

スコア24670

test CHANGED
@@ -71,3 +71,65 @@
71
71
  BRF(TOC) = 0.017508
72
72
 
73
73
  ```
74
+
75
+
76
+
77
+ 追加
78
+
79
+
80
+
81
+ - 最終的にnp.array([0.032158,0.025618,0.022093,0.020022,0.018834,0.018117,0.017508])にような配列にしたい
82
+
83
+
84
+
85
+ ```python
86
+
87
+ import numpy as np
88
+
89
+ import re
90
+
91
+
92
+
93
+ with open('filename') as f:
94
+
95
+ text = f.read()
96
+
97
+
98
+
99
+ blank, *table_list = re.split('(LAI=\d*.0)\n', text)
100
+
101
+ for i in range(0, len(table_list), 2):
102
+
103
+ BRFlist.append(np.loadtxt(io.StringIO(table_list[i+1]), skiprows=1, usecols=[2])[0])
104
+
105
+
106
+
107
+ BRFarray = np.array(BRFlist)
108
+
109
+ ```
110
+
111
+ です。
112
+
113
+
114
+
115
+ 実行結果
116
+
117
+ ```python
118
+
119
+ >>> BRFlist = []
120
+
121
+ >>> for i in range(0, len(table_list), 2):
122
+
123
+ ... BRFlist.append(np.loadtxt(io.StringIO(table_list[i+1]), skiprows=1, usecols=[2])[0])
124
+
125
+ ...
126
+
127
+ >>> BRFarray = np.array(BRFlist)
128
+
129
+ >>> BRFarray
130
+
131
+ array([0.032158, 0.025618, 0.022093, 0.020022, 0.018834, 0.018117,
132
+
133
+ 0.017508])
134
+
135
+ ```