8000 Comments not ignored in genfromtxt when names=True · Issue #9878 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Comments not ignored in genfromtxt when names=True #9878
Closed
@dfreese

Description

@dfreese

The following example runs into an error

import numpy as np
from io import StringIO

s = StringIO(u'''# This comment should be ignored
field_name_0 field_name_1
0 1
2 3''')
data = np.genfromtxt(s, names=True)

The first line, minus the comment delimiter is being taken as the names for the dtype, causing the following error.

ValueError: Some errors were detected !
Line #2 (got 2 columns instead of 5)
Line #3 (got 2 columns instead of 5)
Line #4 (got 2 columns instead of 5)

This seems inconsistent with the fact that the following is fine, and that the documentation for the names and comments fields does not suggest this behavior.

import numpy as np
from io import StringIO

s = StringIO(u'''field_name_0 field_name_1
# This comment should be ignored
0 1
2 3''')
data = np.genfromtxt(s, names=True)

Was this behavior intended? If so I would like to update the documentation on the names field. If not, I'd change the names=True to ignore lines that are entirely comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0