Skip to content

read_fwf - parsers.py PythonParser._rows_to_columns line 2814 object of type 'NoneType' has no len() #19436

Closed
@C5G6M7

Description

@C5G6M7

Line 2814 in parsers.py throws an error if self.delimiter is None:

"object of type 'NoneType' has no len()"

Here is the current line of code where the error happens:

if len(self.delimiter) > 1 and self.quoting != csv.QUOTE_NONE:
    # see gh-13374
    reason = ('Error could possibly be due to quotes being '
        'ignored when a multi-char delimiter is used.')
    msg += '. ' + reason

I propose the following fix, which I believe should be a safe replacement:

if self.delimiter is not None and len(self.delimiter) > 1 and self.quoting != csv.QUOTE_NONE:

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.4.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.20.3
pytest: 3.2.1
pip: 9.0.1
setuptools: 36.5.0.post20170921
Cython: 0.26.1
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.1.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.8
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 0.9.8
lxml: 3.8.0
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: 1.1.13
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIO DataIO issues that don't fit into a more specific labelNeeds InfoClarification about behavior needed to assess issuegood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions