프로그래밍/python
파이썬 xls 파일에서 특정값 추출
콘솔워크
2022. 1. 25. 10:22
반응형
openpyxl does not support the old .xls file format, please use xlrd to read this file, or convert it to the more recent .xlsx file format.
openpyxl 라이브러리를 사용하면 엑셀 특정값 가져오기 쉽다. 하지만 xls 확장자는 지원하지 않았다.
그래서 찾은 방법은 xlrd 라이브러리를 사용하는 것이다.
import xlrd
book = xlrd.open_workbook("myfile.xls")
print("The number of worksheets is {0}".format(book.nsheets))
print("Worksheet name(s): {0}".format(book.sheet_names()))
sh = book.sheet_by_index(0)
print("{0} {1} {2}".format(sh.name, sh.nrows, sh.ncols))
print("Cell D30 is {0}".format(sh.cell_value(rowx=29, colx=3)))
for rx in range(sh.nrows):
print(sh.row(rx))
https://pythonrepo.com/repo/python-excel-xlrd
Please use openpyxl where you can... | PythonRepo
python-excel/xlrd, xlrd xlrd is a library for reading data and formatting information from Excel files in the historical .xls format. Warning This library will no longer
pythonrepo.com
반응형