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
Do not throw exception when line size mismatch #22
Conversation
Hi @chameleooo and @vleroy Many thanks for submitting ideas for improvements and even pull-requests! Awesome! I think there are a few issues we need to clear before we can accept the idea and changes to the main repository.
Now there are alternatives to solving you issue in a more flexible manner than the suggested pull request.
I hope we can get a discussion going rather than you guys feel that I'm plain rejecting you. Also please feel free to help out on some of the existing issues that need fixing. Before coding or sending pull requests, please discuss the issue with us first, -Kasper |
Yeah CSV with variable columns is a difficult problem. There's a recipe for using I'd agree with Kasper regarding the PR - it works in this particular situation but introduces weird behaviour for other situations. For example, if I use |
James, where's the "like button" ?? :-) |
Below text moved to #23 . Please discuss there I was thinking that maybe we could introduce TryReadxxx() methods on the reader implementations which do not throw exceptions, rather they may return null/an empty list maybe along with a list of strings for the caller to inspect and react upon. In C# "out parameters" are typically used with TryXXX methods. I'm not sure what to use in Java. Especially if we want to keep compatibility with java 1.5 something like
What are your thoughts? If you all think its a nice idea, I would not mind @vleroy to submit a PR for that. |
Hi guys, First of all, thanks for quick responses. I'm Victor (chameleooo and vleroy are my personal and professional aliases).
I don't want to deal with optional columns but I think that if we ask user to pass a String[], we can assume that other columns have to be ignored. I don't use CellProcessors but I assume that both methods should be consistent. |
Hmm thinking about it, I think it may be reasonable to add a reader configuration option This option has to be implemented for all the readers. @vleroy What do you think of this idea? |
I don't really understand why we have to know the line size before parsing it ? |
Hi @chameleooo The problem is that if we have more columns with data in them, we cannot be sure what we are getting out of the file. In many enterprise situations, we are better of rejecting the file than importing wrong data. I can see your situation, but Im not convinced that its a common situation. That being said, if we can get @jamesbassett to agree, I think a nice alternative is to, through configuration, to allow one or more EMPTY cells to exist without raising exceptions. It will solve your problem, and it will still keep the reading process sane. |
I understand that in almost every case, you should reject the file if it does not have the same number of columns as expected. But, IMHO, there is no difference between removing empty or not empty trailing cells. And it's just an optional behaviour. |
I think it conflicts with the principle of least surprise. I think the code would be more readable if you read the lines using the |
Ok, I'll implement a Reader for my own needs. |
No problem, thanks for taking the time to discuss future improvements of the framework |
Just found another motivation for supporting trailing empty cells - the google csv export |
Closing this PR - further discussion is moved to #25 |
Hi,
I have a problem using supercsv. Sometimes, I have to deal with some "incorrect" CSV files like that :
"header1";"header2"
"value1";"value2";
As you can see, I have 2 headers and 3 values in the second line. This prevent me from doing a partial read. This is the same case when executing CellProcessors.
Is it ok for you ?