Conversation
jan-petr
left a comment
There was a problem hiding this comment.
Sorry, but this needs a complete overhaul. Can you send the wrong file?! And I'll code it nicely.
|
Great refactoring, but you now report and fix all empty cells; whereas we only should report and fix the empty cells at the end of lines (so too many delimiters at end of lines). Details: 171 "If there's a single line-end only in the data, then consider everything a single line a divide (if possible) by the number of columns" -> what do you mean? difficult to read 174 rem(numel(d{1}, N) -> this used to be the check if we can reshape by number of columns, so this check is now redundant? 208 Am I correct that you are here filling empty cells with empty strings? That's not what we should do. Empty cells are not the problem (if they were, this should be filled with 'n/a' per BIDS (or NaN)). By the way, difficult to read for me, I need more comments ;) 217 -> this warning is incorrect, it should only warn for empty cells at row ends, not for any empty cells 222 -> this warning is correct! We should add +1 though to compensate for the header.
|
It fixes too much or too little cells per line. It reports all empty for convenience of user that he knows he has empty cells, but I can disable that. HENK: Thanks, no it should only report the illegal empty cells at end of lines (222).
If cells are empty, then they are initialised as empty. I am only changing type of the empty cell from double to char. Because all the read cells are chars. HENK: Are you sure it won't read any cells as numeric? If all cells are read as char then this is fine of course; otherwise this is just redundant code and we can skip this whole part. We don't care about empty cells that are not at the eol.
I added +1 to compensate for header.
HENK: ??? NEW TEST: It still mentions all empty cells. It should only mention the empty cells at the end of the line (making a line having more cells than the header has). Did you remove the wrong warning? The warning on line 222 was correct, the warning on line 217 was incorrect. The code still doesn't remove empty cells at the end of the line... It should remove the empty cells at the end of the line, such that the number of delimiters is the same for each line. |
|
The function textscan treats a last empty cell (so a delimiter follow by line-end) as a non-existing cell (not empty, but completely skipping it). So "text,text,text EOL" is three cells (comma being a delimiter). "text,,,text EOL" is four cells. But "text, EOL" one cell. Though "text,,EOL" two cells. So I've inserted an extra fix that adds an extra cell at the end of the line if it ends with a delimiter. Now it all works. |
|
Funnily, I think that none of the changes were necessary for the |
71eded8 to
52171bf
Compare


Linked issue
Closes #1140
How to test
Required: if not defined in the linked issue, add a simple test description here
Comments
Optional: add helpful comments for the reviewers here