read_csv: read file as binary when encoding_errors is set to ignore #1723
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Feature or Bugfix
Detail
read_csv
chokes on encoding errors even when passingencoding_errors='ignore'
. This happens due to ours casting the S3 object toTextIOWrapper
after retrieving it and passing that topd.read_csv
.encoding_errors='ignore'
we now keep the object as a set of bytes (mode=rb
). In this case pandas is now responsible for wrapping this in a TextIOWrapper and deals with encoding and encoding errors.I'm actually thinking we should never wrap the S3 object into a TextIOWrapper ourselves - as far as I can tell there is no advantage doing that and pandas will take care of it anyway.
mode
should always be set torb
in our code... but I'm curious about others' opinion!Relates
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.