import csv #德明科大劉任昌修改11與16列 f = open('00960.csv','r',encoding='utf-8') csv_reader = csv.reader(f) header, rows = [], [] #宣告空白串列(陣列,清單) header = next(csv_reader) #串列header存放第一列標題 for row in csv_reader: #逐列讀檔案、附加append於rows串列 rows.append(row) f.close() idSet = set() component = dict() #zeros = [0 for i in range(21)] for row in rows: for j in range(0, 21): idSet.add(row[j*4]) for id in idSet: component[id] = [0 for i in range(21)] #取代原來的zeros for row in rows: for j in range(0, 21): if row[j*4+3] != '': component[row[j*4]][j] = row[j*4 + 3] print(row[j*4+1],component[row[j*4]]) for id in idSet: print(id, component[id]) 原來 修改後
https://hsu-wei-cheng.blogspot.com/2024/02/blog-post.html
回覆刪除https://algorithmic-trading-takmingd11017140.blogspot.com/2024/02/blog-post.html
回覆刪除https://zxcv901026.blogspot.com/2024/02/20172021.html
回覆刪除https://g239.blogspot.com/2024/02/20172021.html
回覆刪除https://stephen-ky.blogspot.com/2024/02/20172017-d11017312.html
回覆刪除https://liyuantsao.blogspot.com/2024/02/2017.html
回覆刪除