KOTA ITO

Generation

generate functionThu, 15 Dec 2022

openpyxlを使う。Excelファイルの3列目に含まれる日付でデータをグルーピングする。 グルーピングしたデータを別々のシートに分割する。シートの名前には日付を入れる。

import openpyxl # 日付を文字列で取得 def get_date(value): if value: return value.strftime("%Y/%m/%d") else: return "" # ws:ワークシート def grouping(ws): # グルーピングする列番号 target_column = 3 # グルーピングする日付のリスト target_dates = [] # グルーピングした行番号のリスト target_rows = [] # グルーピングしたデータを入れる辞書 dates_data = {} # 列数 col_size = ws.max_column # 行数 row_size = ws.max_row # 行ごとに、データがあれ

Questions about programming?Chat with your personal AI assistant