[Feature Request] Add ability to trim values for the header row #44
ragingdave
started this conversation in
Ideas
Replies: 2 comments
-
I'd accept a PR with updated docs and tests that improve this. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'll try and get something together some time this week. |
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
-
During usage, we've come across multiple times where the header row of a csv has errant leading or trailing whitespace. This causes processing issues as then the column might be recognized as
test
instead oftest
. I've reviewed old issues and PRs for box/spout and it seems they have made that decision to not trim "cell" values back in 2016, but headers have a bit of a different handling of them and adding an option totrimHeaders
to the configuration of the reader might be something useful.I can certainly work on creating this feature if it were to be a welcome addition as we are looking at options to resolve this human error at the code level.
trimHeaders could basically be a pass-through to trim and allow customization of the characters to remove
so for the most part it would look like this (all untested, just off the cuff here):
and in usage, when the headers are set from $firstRow->toArray(), we would just simply map over them and apply trim optionally if enabled.
Let me know if this would be something that would be worthwhile adding.
Beta Was this translation helpful? Give feedback.
All reactions