You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, in web-csv-toolbox, when parsing a CSV file, the process continues even if the number of columns in each row does not match. While this behavior provides flexibility, some applications may require the detection of column mismatches to ensure data integrity and throw an exception when such mismatches occur.
This issue proposes extending the existing ParseError class to throw an exception when the number of columns in the header row does not match the data rows during CSV parsing. Additionally, an option will be added to allow the user to suppress this exception, enabling flexible operation according to application requirements.
Specification
Throwing an exception for column count mismatches:
During CSV parsing, if a data row has a different number of columns than the header row, a ParseError will be thrown.
The ParseError message will include details such as the row number where the mismatch occurred, the expected number of columns from the header, and the actual number of columns in the data row.
Option to suppress the exception:
To accommodate applications that tolerate column mismatches, an option will be added to suppress the exception.
By default, the exception will be enabled, but the user can disable it by setting an option.
The option will be named allowColumnMismatch (tentative) and will default to false. If set to true, no ParseError will be thrown, and parsing will continue even if there is a column count mismatch.
Expected Use Cases
When data integrity is crucial:
Users can treat column mismatches as ParseError exceptions, preventing any inconsistencies in the data.
When flexible CSV parsing is required:
If the application needs to tolerate column count discrepancies, the user can suppress the exception using the option, allowing for more flexible data handling.
The text was updated successfully, but these errors were encountered:
Overview
Currently, in
web-csv-toolbox
, when parsing a CSV file, the process continues even if the number of columns in each row does not match. While this behavior provides flexibility, some applications may require the detection of column mismatches to ensure data integrity and throw an exception when such mismatches occur.This issue proposes extending the existing
ParseError
class to throw an exception when the number of columns in the header row does not match the data rows during CSV parsing. Additionally, an option will be added to allow the user to suppress this exception, enabling flexible operation according to application requirements.Specification
Throwing an exception for column count mismatches:
ParseError
will be thrown.ParseError
message will include details such as the row number where the mismatch occurred, the expected number of columns from the header, and the actual number of columns in the data row.Option to suppress the exception:
allowColumnMismatch
(tentative) and will default tofalse
. If set totrue
, noParseError
will be thrown, and parsing will continue even if there is a column count mismatch.Expected Use Cases
When data integrity is crucial:
When flexible CSV parsing is required:
The text was updated successfully, but these errors were encountered: