作者wergbm501 (懵懂巴巴)
看板Python
标题[问题] python 2.7读取excel
时间Fri Nov 4 16:50:47 2016
大家好
我很不会用Python 但是大学专题需要我用到
所以我问了学长姐跟他们拿了档案
想说可以学习看看
所以我就一步一步逐段打
但殊不知一开始就遇到了问题
以下是我的程式码
第一段
import pandas as pd
from bokeh.io import output_file, show
from bokeh.plotting import *
import numpy as np
第二段
text1=pd.read_excel("map1.xlsx")
结果就跑出
IOError Traceback (most recent call last)
<ipython-input-6-b13e7578b335> in <module>()
----> 1 text1=pd.read_excel("map1.xlsx")
C:\Anaconda2\lib\site-packages\pandas\io\excel.pyc in read_excel(io, sheetname, header, skiprows, skip_footer, index_col, parse_cols, parse_dates, date_parser, na_values, thousands, convert_float, has_index_names, converters, engine, **kwds)
161
162 if not isinstance(io, ExcelFile):
--> 163 io = ExcelFile(io, engine=engine)
164
165 return io._parse_excel(
C:\Anaconda2\lib\site-packages\pandas\io\excel.pyc in __init__(self, io, **kwds)
204 self.book = xlrd.open_workbook(file_contents=data)
205 else:
--> 206 self.book = xlrd.open_workbook(io)
207 elif engine == 'xlrd' and isinstance(io, xlrd.Book):
208 self.book = io
C:\Anaconda2\lib\site-packages\xlrd\__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows)
392 peek = file_contents[:peeksz]
393 else:
--> 394 f = open(filename, "rb")
395 peek = f.read(peeksz)
396 f.close()
IOError: [Errno 2] No such file or directory: 'map1.xlsx'
不知道是我的excel档放错地方还是哪里有问题呢
希望各位前辈可以指导我谢谢
-----
Sent from JPTT on my HTC One 801e.
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 115.82.146.94
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1478249449.A.00C.html
1F:推 infit: 路径错误 11/04 16:53
2F:→ wergbm501: 那我应该要放在哪里呀 我有试着放在我的使用者下面 仍 11/04 17:15
3F:→ wergbm501: 然无法QQ 11/04 17:15
4F:推 infit: 终端机打pwd 11/04 17:50
5F:→ wergbm501: 哇可以 我打了pwd显示是桌面 所以我就把东西都拖到桌面 11/04 18:39
6F:→ wergbm501: 果然可以 11/04 18:39
7F:→ wergbm501: 谢谢大家 11/04 18:39