Skip to content

Specify fixed number of columns in parser, break if mismatch #2711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wesm opened this issue Jan 20, 2013 · 1 comment
Closed

Specify fixed number of columns in parser, break if mismatch #2711

wesm opened this issue Jan 20, 2013 · 1 comment
Labels
Enhancement IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@wesm
Copy link
Member

wesm commented Jan 20, 2013

cf #2430

I'm still having problems with this:

data = ('a:b\n'
'c:d:e\n'
'f:g:h:i\n'
'j:k\n'
'ln\n')

##if first row does not match longest line length, you error out doing this
print pandas.read_csv(StringIO(data),header=None,sep=':')
##even if u specify names..
print pandas.read_csv(StringIO(data),header=None,sep=':',names=list(np.arange(4)))

It would be really awesome if there was a way to force the parser to expect a fixed number of columns.
@wesm
Copy link
Member Author

wesm commented Apr 8, 2013

This is fixed now in master from separate work:

In [3]: read_csv(StringIO(data),header=None,sep=':',names=list(np.arange(4)))
Out[3]: 
    0    1    2    3
0   a    b  NaN  NaN
1   c    d    e  NaN
2   f    g    h    i
3   j    k  NaN  NaN
4  ln  NaN  NaN  NaN

@wesm wesm closed this as completed Apr 8, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

No branches or pull requests

1 participant