Skip to content
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

Non-rectangular table with fewer columns than header values causes failures downstream #313

Closed
evz opened this issue Aug 25, 2014 · 2 comments
Labels

Comments

@evz
Copy link

evz commented Aug 25, 2014

When attempting to run the convert against a file that had fewer columns in the main body of the file than columns in the header, I found that I was only getting the header row back, not the body of the file. When I dug deeper into the issue, it seems that, while there is code in Table.from_csv that seems to be in place to truncate data from rows that are wider than the header, it does not work when the opposite situation is true (header that is wider than the body). While that does not seem to be a problem for data on the way in, a failure seems to happen when the Python zip function gets called on the way out in the Table.to_csv method. That call basically collapses the entire body of the table into an empty list (since the last column is, effectively an empty list) which then causes the convert function to just return the header.

To illustrate this, the csv that I was dealing with looked a little like this:

this,is,the,header
here,is,data
more,data,here

You'll notice that whatever created the file originally forgot to put commas on the ends of those rows. While this is clearly a violation of the csv spec, it seems like something that is pretty simple to handle.

I realize this is one of those situations where you're probably not going to be able to make everyone happy all the time, but it would seem that there's a way to either fill that empty column with None or just truncate the header. I'd be happy to submit a pull request if one of these approaches seems to be better than the other (or maybe something else?).

@onyxfish
Copy link
Collaborator

onyxfish commented Sep 5, 2014

Whoa, nice catch. Looking into this.

@evz
Copy link
Author

evz commented Sep 6, 2014

Hey cool, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants