1
の呼び出し中:例外TypeError私はいくつかのテーブルを持つファイルと、このエラーを取得維持エクセルを開くしようとしているpandas.ExcelFile
TypeError: unsupported operand type(s) for <<: 'str' and 'int'
は、これは私のコードです:また
import pandas as pd
from pathlib import Path
import sys
def file_lister(path, extension=None):
if extension is None:
return list(path.glob('*'))
else:
return list(path.glob('*' + extension))
fpath = Path().resolve().parent
fname = 'Accounts 2017 varios.xlsx'
try:
io = list(fpath.glob(fname))[0]
except IndexError:
file_list = file_lister(fpath, 'xlsx')
raise Warning(('{} not founded. Available files:' + '\n\t{}' * len(
file_list)).format(fname, *[file for file in file_list]))
encoding = 'latin-1'
xl = pd.ExcelFile(io.open(encoding=encoding))
、私が手同じエラーを使用して:
pd.read_excel(io.open(encoding=sys.getfilesystemencoding()))
私はopen()でファイルを正常に開くことができます。
私は窓の8.1
任意の手がかりでPython 3.4とパンダ0.16.2を使用していますか?
を例外が発生したライン何で? – EndermanAPM
open()を使用するときに、「b」を追加してExcelファイルをバイナリファイルに指定できますか?たとえば、 'io.open(encoding = encoding、 'rb')' – SSC
io.open( 'rb')が働いてくれてありがとう – Mstaino