스프레드 시트를 반복하고 특정 열 아래의 행에서 셀 값을 가져 오려고합니다.
# Row by row, go through the originalWorkSheet and save the values from the selected columns
numberOfRowsInOriginalWorkSheet = originalWorkSheet.nrows - 1
rowCounter = 0
while rowCounter <= numberOfRowsInOriginalWorkSheet:
row = originalWorkSheet.row(rowCounter)
#Grab the values in certain columns, say with the
# column name "Promotion" and save them to a variable
이게 가능해? 내 google-foo가 이것에 대해 나를 실패했습니다. 도와 주셔서 감사합니다!
가장 간단한 방법 :
from xlrd import open_workbook
book = open_workbook(path_to_file)
sheet = book.sheet_by_index(0)
for i in range(1, sheet.nrows):
row = sheet.row_values(i)
variable = row[0] # Instead zero number of certain column
또는 행 목록을 반복하고 각 셀 값을 인쇄 할 수 있습니다.
book = open_workbook(path_to_file)
sheet = book.sheet_by_index(0)
for i in range(1, sheet.nrows):
row = sheet.row_values(i)
for cnt in range(len(row)):
print row[cnt]
도움이 되었기를 바랍니다
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다