で長さが異なる行からリストを作成する:が、私はこのようになります私のデータのpythonで各列のリストを作成しようとしていますのpython
399.75833 561.572000000 399.75833 561.572000000 a_Fe I 399.73920 nm
399.78316 523.227000000 399.78316 523.227000000
399.80799 455.923000000 399.80799 455.923000000 a_Fe I 401.45340 nm
399.83282 389.436000000 399.83282 389.436000000
399.85765 289.804000000 399.85765 289.804000000
問題は、私のデータの各行がAであるということです異なる長さ。とにかく、短い行の残りのスペースをスペースでフォーマットして、同じ長さになるようにしますか?
私は形であることに私のデータを希望:
list one= [399.75833, 399.78316, 399.80799, 399.83282, 399.85765]
list two= [561.572000000, 523.227000000, 455.923000000, 389.436000000, 289.804000000]
list three= [a_Fe, " ", a_Fe, " ", " "]
これは私のpythonにデータをインポートするために使用するコードです:
fh = open('help.bsp').read()
the_list = []
for line in fh.split('\n'):
print line.strip()
splits = line.split()
if len(splits) ==1 and splits[0]== line.strip():
splits = line.strip().split(',')
if splits:the_list.append(splits)