質問編集履歴

2

現在の読み込み部分のコードを追記しました。

2019/01/16 04:21

投稿

mah3
mah3

スコア17

test CHANGED
File without changes
test CHANGED
@@ -26,9 +26,7 @@
26
26
 
27
27
 
28
28
 
29
-
29
+ ```
30
-
31
-
32
30
 
33
31
  file = open('test.txt','r')
34
32
 
@@ -90,4 +88,6 @@
90
88
 
91
89
 
92
90
 
93
- print('READ FINISH.');
91
+ print('READ FINISH.');
92
+
93
+ ```

1

現在の読み込み部分のコードを追記しました。

2019/01/16 04:21

投稿

mah3
mah3

スコア17

test CHANGED
File without changes
test CHANGED
@@ -23,3 +23,71 @@
23
23
  BBB(要) 547.....
24
24
 
25
25
  XXX(不要) 547....
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+ file = open('test.txt','r')
34
+
35
+ string = file.readline()
36
+
37
+ string = file.readline()
38
+
39
+
40
+
41
+ x = [0]*10000
42
+
43
+ y = [0]*10000
44
+
45
+ z = [0]*10000
46
+
47
+ array_number = [0]*10000 #配列番号
48
+
49
+ tag = [0]*10000 #物質名
50
+
51
+ atom = [0]*10000 #原子名
52
+
53
+ chain = [0]*10000 #鎖
54
+
55
+
56
+
57
+ #最初の読み込み------------------------------------
58
+
59
+ cnt = 0
60
+
61
+ while string:
62
+
63
+ cnt = int(string[6:11],10)
64
+
65
+ if string[36] == ' ':
66
+
67
+ string = file.readline()
68
+
69
+ continue
70
+
71
+
72
+
73
+ x[cnt] = float(string[31:38])
74
+
75
+ y[cnt] = float(string[39:46])
76
+
77
+ z[cnt] = float(string[47:54])
78
+
79
+ array_number[cnt] = float(string[22:26])
80
+
81
+ tag[cnt] = string[17:20]
82
+
83
+ atom[cnt] = string[13:16]
84
+
85
+ chain[cnt] = string[21]
86
+
87
+
88
+
89
+ string = file.readline()
90
+
91
+
92
+
93
+ print('READ FINISH.');