-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
Code Sample, a copy-pastable example if possible
import pandas path = "test.csv" pandas.DataFrame({"A": [0,1], "B": [2,3]}).to_csv( path, encoding="utf-16") for encoding in ["utf-16","utf_16","UTF_16","UTF-16"]: try: pandas.io.parsers.read_csv( path, engine='c', encoding=encoding) print(encoding, "succeeded in c-pandas") except UnicodeDecodeError: print(encoding, "failed in c-pandas") try: pandas.io.parsers.read_csv( path, engine='python', encoding=encoding) print(encoding, "succeeded in pandas") except UnicodeDecodeError: print(encoding, "failed in pandas") try: with open(path, encoding=encoding) as file: file.read() print(encoding, "succeeded in open") except UnicodeDecodeError: print(encoding, "failed in open") Expected Output
utf-16 succeeded in c-pandas utf-16 succeeded in pandas utf-16 succeeded in open utf_16 succeeded in c-pandas utf_16 succeeded in pandas utf_16 succeeded in open UTF_16 succeeded in c-pandas UTF_16 succeeded in pandas UTF_16 succeeded in open UTF-16 succeeded in c-pandas UTF-16 succeeded in pandas UTF-16 succeeded in open Actual Output
utf-16 succeeded in c-pandas utf-16 succeeded in pandas utf-16 succeeded in open utf_16 failed in c-pandas utf_16 succeeded in pandas utf_16 succeeded in open UTF_16 failed in c-pandas UTF_16 succeeded in pandas UTF_16 succeeded in open UTF-16 failed in c-pandas UTF-16 succeeded in pandas UTF-16 succeeded in open output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.6.2-1-ARCH
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
pandas: 0.18.1
nose: 1.3.7
pip: 8.1.1
setuptools: 23.0.0
Cython: None
numpy: 1.11.0
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None