-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
read_csv incompatible with newstr and future #14477
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
Comments
@jorisvandenbossche : Might it be best to just add a try:
unicode
except NameError:
unicode = str |
FYI, for future reference, here's a slightly easier way to reproduce (Note: Python 2.x required): >>> from pandas import read_csv
>>> from pandas.compat import StringIO, u
>>>
>>> data = 'a\n1'
>>> read_csv(StringIO(data), quotechar=u('"'))
...
TypeError: "quotechar" must be string, not unicode |
@gfyoung unicode needs to be very explicit |
well it's not explicit |
In pandas.compat: try:
unicode
except NameError:
unicode = str
... In parser.pyx: if not isinstance(quote_char, (str, bytes, compat.unicode)) and quote_char is not None:
... |
…d.read_csv Title is self-explanatory. Affects Python 2.x only. Closes pandas-dev#14477. Author: gfyoung <[email protected]> Closes pandas-dev#14492 from gfyoung/quotechar-unicode-2.x and squashes the following commits: ec9f59a [gfyoung] BUG: Accept unicode quotechars again in pd.read_csv (cherry picked from commit 6130e77)
having a similar problem with 'escapechar'
|
When upgrading the pandas-0.19 I have several tests failing on a package I maintain. These packages are using several imports from future to work with both py2 and py3. It seems there is an issue with using
from __future__ import unicode_literals
A small, complete example of the issue
The first reading works the second does not and throws the stack trace attached. ("TypeError: "quotechar" must be string, not unicode")
The example file
simple.txt
Expected Output
Output of
pd.show_versions()
commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: None.None
pandas: 0.19.0
nose: 1.3.7
pip: 8.1.2
setuptools: 26.0.0
Cython: None
numpy: 1.11.2
scipy: 0.16.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.3.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.7
blosc: None
bottleneck: None
tables: None
numexpr: 2.4.6
matplotlib: 1.5.1
openpyxl: None
xlrd: 0.9.4
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.42.0
pandas_datareader: None
The text was updated successfully, but these errors were encountered: