複数のシートを持つxlsxファイルがあります。シートには、列A にタイムスタンプ(文字列として)があります。どのくらいの時間が経過したかを見るために、上のものから細胞を引く必要があります。Pythonのxlsxファイルの1つ前のセルから1つの列のセルを引きます。
ex。 COLUMN A
02/23/2017 08:25:39
02/23/2017 08:55:56
02/23/2017 08:55:57
02/23/2017 08:56:12
これは私が今までに持っているものです.....事前にありがとうございます。
import xlrd
from datetime import datetime
def open_file(path):
# Open and read an Excel file
book = xlrd.open_workbook(path)
# get the first worksheet
first_sheet = book.sheet_by_index(0)
# read first column
column_values = first_sheet.col_values(0,0)
column_list = []
for i in column_values:
i = datetime.strptime(i, '%m/%d/%Y %H:%M:%S')
column_list.append(i)
print(column_list[1] - column_list[0])
if __name__ == "__main__":
path = '02-23-2017.xlsx'
open_file(path)
私をprint文は一番下にありますが、何千ものタイムスタンプがありますので、プログラマチックにそれらを通過する方法が必要です。ありがとう – Al123