-
Notifications
You must be signed in to change notification settings - Fork 5
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
chore: improve error message for missing header in input csv files #498
chore: improve error message for missing header in input csv files #498
Conversation
ECALC-773
@@ -396,7 +400,7 @@ def _validate_headers(headers: List[str]): | |||
"[ _ - # + : . , /] " | |||
) | |||
elif re.match(r"^Unnamed: \d+$", header): | |||
raise ValueError("CSV input file must include header") | |||
raise InvalidResourceHeaderException(f"One or more headers are missing in input-file {name}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my opinion we should probably not have a naution about filename here. It may not always be a filename, it may be a csv dataset retrieved from another place? Therefore, a specific exception as you have here is good, and then catch that higher up, where you can add the additional information about the filename. how does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good. To understand, higher up - you mean to catch it later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Basically, if we have an error reading a csv file we would probably have to "stop the line", as in stop execution in order for the user to fix the error to continue? So, yes, as late as possible, higher up the hierarchy, where we are actually trying to read a file called "test.csv", or a data stream...which in theory is also possible...close to the error you have the details of what went wrong (characters on the specific line aso.), and higher up you have the details of the greater task (read a file)..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TeeeJay : The error is now catched differently. Please have a look and see if it is better.
ECALC-773
Co-authored-by: Thomas Falch Johansen <[email protected]>
) * chore: improve error message for missing header in input csv files ECALC-773 --------- Co-authored-by: Thomas Falch Johansen <[email protected]>
ECALC-773
Have you remembered and considered?
docs/docs/changelog/next.md
)docs/docs/migration_guides/
)BREAKING:
in footer or!
in header, if breakingECALC-XXXX
)Why is this pull request needed?
eCalc correctly points to error in csv file, when missing headers. The name of the file is not given. This can make it difficult /time consuming for the user to debug - if many files.
What does this pull request change?
Improving error message with filename, creating a new Exception.
Issues related to this change:
https://equinor-ecalc.atlassian.net/browse/ECALC-773?atlOrigin=eyJpIjoiNTBiZjFmNmVhOGE3NGExOWE4OTliZjg1ODM4NDRiNjQiLCJwIjoiaiJ9