[Tutor] NumPy Generates ValueError: Some errors were detected ! Line #9 (got 42 columns instead of 1)

Stephen P. Molnar s.molnar at sbcglobal.net
Sat Sep 28 15:23:37 EDT 2019


On 09/28/2019 12:36 PM, Stephen P. Molnar wrote:
>
>
> On 09/27/2019 12:22 PM, Alan Gauld via Tutor wrote:
>> On 27/09/2019 12:47, Stephen P. Molnar wrote:
>>> 6714-6.210.5192.90RANKING 6811-6.140.9892.78RANKING
>>> 6920-6.110.7192.67RANKING 61019-6.011.3693.00RANKING
>>> 7112-6.300.0093.28RANKING 814-5.850.0092.97RANKING
>>> _______________________________________________________________________| 
>>>
>>>
>>> and the error is:
>>>
>>> errors were detected ! Line #29 (got 1 columns instead of 7)|
>>>
>> It looks like your data is separated by periods. But I don't see how you
>> tell
>> Python that fact? I suspect there should be something like a
>> separator='.' argument in there somewhere?
>>
>>
>> I don't know the numpy stuff at all so can only surmise but that's
>> what I'd expect.
>>
>  Thank you for your reply. There are, in fact, hidden characters in 
> the input file (cat -A ...):
>
>> ^IRMSD TABLE$
>> ^I__________$
>> $
>> _____________________________________________________________________$
>>      |      |      |           |         |                 |$
>> Rank | Sub- | Run  | Binding   | Cluster | Reference       | Grep$
>>      | Rank |      | Energy    | RMSD    | RMSD            | Pattern$
>> _____|______|______|___________|_________|_________________|___________$
>>    1      1      8       -7.23      0.00     93.07 RANKING$
>>    1      2      9       -6.79      1.39     92.64 RANKING$
>>    2      1     16       -7.18      0.00     93.19 RANKING$
>>    3      1      2       -6.93      0.00     93.38 RANKING$
>>    3      2     17       -6.84      0.23     93.45 RANKING$
>>    4      1     15       -6.55      0.00     91.83 RANKING$
>>    4      2      7       -6.34      0.33     91.77 RANKING$
>>    5      1      5       -6.41      0.00     93.05 RANKING$
>>    6      1      3       -6.36      0.00     92.84 RANKING$
>>    6      2     10       -6.28      0.47     92.92 RANKING$
>>    6      3      6       -6.27      0.43     92.82 RANKING$
>>    6      4     18       -6.25      0.32     92.88 RANKING$
>>    6      5     13       -6.24      0.96     92.75 RANKING$
>>    6      6      1       -6.24      0.87     92.60 RANKING$
>>    6      7     14       -6.21      0.51     92.90 RANKING$
>>    6      8     11       -6.14      0.98     92.78 RANKING$
>>    6      9     20       -6.11      0.71     92.67 RANKING$
>>    6     10     19       -6.01      1.36     93.00 RANKING$
>>    7      1     12       -6.30      0.00     93.28 RANKING$
>>    8      1      4       -5.85      0.00     92.97 RANKING$
>> _______________________________________________________________________$
> but no periods.
>

As much as I wish I could claim that it was a stroke of genius on my 
part, I'm sure that it was just dumb luck, but I have solved the problem.

The correct liner of code is:

data = np.genfromtxt(name_in, usecols=(3), dtype=None, skip_header=8, 
skip_footer=1, encoding=None)

This results in extracting the Binding Energy from the data table, which 
is the desired result.

-- 
Stephen P. Molnar, Ph.D.            Life is a fuzzy set
http://www.Molecular-Modeling.net   Multivariate and stochastic
614.312.7528 (c)
Skype:  smolnar1



More information about the Tutor mailing list