0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python エクセルが読めない print “EXTERNSHEET(b7-):” pandas エラー対応の例

Posted at

pythonで急にエクセルが読めなくなった

「Python による経済・経営分析のための実践的データサイエンス」第5章 (pp.136-160) サンプル

import pandas as pd
input_book = pd.ExcelFile('AB_NYC_2019_2.xlsx')

こんなエラー

  File "/path to/python3.9/site-packages/xlrd/__init__.py", line 1187
    print "EXTERNSHEET(b7-):"
                            ^
SyntaxError: invalid syntax

とりあえずアップグレード

% pip install --upgrade xlrd 

今度はこんなエラー

  168     # files that xlrd can parse don't start with the expected signature.
    169     if file_format and file_format != 'xls':
--> 170         raise XLRDError(FILE_FORMAT_DESCRIPTIONS[file_format]+'; not supported')
    171 
    172     bk = open_workbook_xls(

XLRDError: Excel xlsx file; not supported

openpyxl で対応
入ってなかったらインストール

% pip install openpyxl

コードをこんなふうに変更する

import pandas as pd
input_book = pd.ExcelFile('AB_NYC_2019_2.xlsx', engine='openpyxl')

できた!

スクリーンショット 2021-07-24 12.53.47.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?