CSV: provide column number and just the relevant cell on error#418
CSV: provide column number and just the relevant cell on error#418Artoria2e5 wants to merge 2 commits intowikimediabrasil:mainfrom
Conversation
src/core/parsers/csv.py
Outdated
|
|
||
| for index, cell in enumerate(row): | ||
| cell_value = cell.strip() | ||
| debuginfo = f"Column {index}: {cell_value}" |
There was a problem hiding this comment.
I think we should avoid english language in the code in a way that's not translatable. But I also don't know which syntax would look better. Just the cell_value maybe?
There was a problem hiding this comment.
The col index is important additional info for locating the error, as cell_value can be repeated. I think "column" is some word everyone who deals with a database ends up learning and it actually beats many localized alternatives in terms of clarity (e.g. zh-CN has 行 列 for row, col but zh-TW has 列 行 for row, col). Translation of any debugging information is dubious to an extent.
For maximizing information content I would go for:
f"{index=},\n{header_value=}\n{cell_value=},"
There was a problem hiding this comment.
@Artoria2e5 I kept wondering about this. I think qid should be present and index is not necessary. The thing about raw and specially how it's given in the report for the user is that it's useful to use to just rerun a specific command or take it as it is and modify it. The thing is that in CSV that is not kind of possible. We could recreate a micro-csv like ,{header}\n{qid},{cell}, which would be a way to go.
Other than that, we could havfe ({qid}) {header_value}: {cell_value}, what do you think?
Updated debuginfo to include header information.
Fix #417