null in reader #150
Unanswered
petrvosahlo-cnrd
asked this question in
Q&A
Replies: 1 comment
-
FastCSV provides a null-free API, ensuring that no public function ever returns null. If a field modifier were allowed to return null, the documented behavior of methods like
I have created an example that shows how to handle null values in FastCSV by using a custom |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello @osiegmar,
what would propose as solution for handling nulls instead of empty strings?
I created field modifier to handle empty string to null.
IE: "public enum CustomFieldModifier implements FieldModifier {
}"
later commonly used as
"try (var reader = CsvReader.builder().skipEmptyLines(true).build(NamedCsvRecordHandler.of(c -> c.fieldModifier(CustomFieldModifier.NULL)), csvAsString)) {
return reader.stream().map(this::convertToEntity).toList();
}"
but later in de.siegmar.fastcsv.reader.AbstractInternalCsvCallbackHandler.addField(char[], int, int, boolean) we are doing null.lenght()
So whats the prefered way to handle "" -> null? How to keep NamedCsvRecordHandler functionality without overiding quite a lot from fastcsv package?
Beta Was this translation helpful? Give feedback.
All reactions