-
Notifications
You must be signed in to change notification settings - Fork 3
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
Validate DelimFile headers #17
base: main
Are you sure you want to change the base?
Conversation
@@ -24,6 +24,7 @@ flate2 = "^1" | |||
# For auto-serialization of structs to csv/tsv | |||
csv = "^1" | |||
serde = { version = "^1.0.123", features = ["derive"] } | |||
serde-aux = "^4" |
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.
Used for serde / field name introspection. fqtk
uses the same crate.
@@ -171,8 +171,16 @@ impl<D: DeserializeOwned> DelimFileReader<D> { | |||
.has_headers(true) | |||
.quoting(quote) | |||
.from_reader(reader); | |||
assert!(csv_reader.has_headers(), "Expected input file to have a header row"); |
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.
I removed this assert. It wasn't actually checking for a header line but instead just checks that the reader is configured to read a header.
let header = csv_reader.headers().map_err(FgError::ConversionError)?.to_owned(); | ||
if !header.is_empty() { |
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.
Empty files return empty headers, so we validate headers for only non-empty TSVs.
If this is still the case, could you add a test for it? |
Adds validation to parse DelimFile headers.