-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
BUG: #57954 encoding ignored for filelike #57968
BUG: #57954 encoding ignored for filelike #57968
Conversation
…like' into #57954_encoding_ignored_for_filelike
…ored_for_filelike
pandas/io/parsers/readers.py
Outdated
@@ -1485,6 +1485,17 @@ def _make_engine( | |||
"pyarrow": ArrowParserWrapper, | |||
"python-fwf": FixedWidthFieldParser, | |||
} | |||
|
|||
file_encoding = getattr(f, "encoding", None) |
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.
This check might be better in _check_file_or_buffer
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 like your suggestion, but trying that out the type checking throws errors. None of the annotated classes in _make_engine
guarantee an encoding
attribute, so the getattr
check would be necessary here anyway at least for the type checker.
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.
It's OK adding typing ignores as needed
Thanks @dontgoto |
* add exception when encodings exist and do not match * add exception when encodings exist and do not match * add test for mismatching encodings warning * add test for mismatching encodings warning * add encoding for python 3.10+ * move to _check_file; invert var and condition
read_csv
on FileLike objects #57954