1

I have the file called mda_bk-adds-gro.inp:

# -*- mode:python -*-
0.5, 0.5, 0.5, walp_fixed.gro
0.5, 0.5, 0.4, walp.gro

I think I'll read the numbers and the the word separately. I've succeded in parsing the numbers:

loadtxt('mda_bk-adds-gro.inp', comments='#', delimiter=',', usecols=(0,1,2))

But can't read in just words:

loadtxt('mda_bk-adds-gro.inp', comments='#', delimiter=',', dtype=[('fileName', '|S100')], usecols=(3))

it gives an error:

 TypeError: 'int' object is not iterable

So my question is - how do I read the forth column with loadtxt provided the column is str?

4

1 回答 1

1

你得到的TypeError因为(3)不是一个元组,而只是一个带括号的int类型表达式。试试usecols=(3,)吧。

请参阅此问题的评论以了解为什么会这样。

于 2012-07-31T14:32:58.500 回答