0

以下を含むテキストファイルbat.txtがあります。

  Originator     (#/255)           Nexthop [outgoingIF]:   Potential nexthops ... [B.A.T.M.A.N. adv 0.2-beta r1457, MainIF/MAC: eth0/fe:fe:00:00:01:01]
fe:fe:00:00:05:01  (223) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:03:01 ( 96) fe:fe:00:00:02:01 (223)
fe:fe:00:00:04:01  (233) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:03:01 (100) fe:fe:00:00:02:01 (233)
fe:fe:00:00:02:01  (254) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:02:01 (254) fe:fe:00:00:03:01 (100)
fe:fe:00:00:07:01  (203) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:02:01 (203) fe:fe:00:00:03:01 ( 88)
fe:fe:00:00:08:01  (196) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:03:01 (  0) fe:fe:00:00:02:01 (196)
fe:fe:00:00:03:01  (244) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:03:01 (104) fe:fe:00:00:02:01 (244)
fe:fe:00:00:09:01  (184) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:02:01 (184) fe:fe:00:00:03:01 ( 72)
fe:fe:00:00:06:01  (214) fe:fe:00:00:02:01 [      eth0]: fe:fe:00:00:03:01 ( 76) fe:fe:00:00:02:01 (214)

Originator と Nexthop の列から見出しを除いたものを、2 つのサブリストを含む Python リストにコピーしたい (例: somelist = [[],[]])

with open('bat.txt', 'r') as file:
...     file.readline() # to skip the first line
...     rows = [[int(x) for x in line.split()[:-1]] for line in file]
...     cols = [list(col) for col in zip(*rows)]

これにより、すべての列がリスト col に読み込まれます。必要な列のみを選択する最良の方法は何ですか?

4

1 に答える 1