[英]How to join 2 columns of similar data into a single column in a same excel file with same column headings using python
在這張圖片中,我有 4 列具有重復的列名。 我只需要 2 列,一列用於項目,一列用於數量,所有值都在 2 列中。任何人都可以幫助我。提前致謝。
如果您可以在此處閱讀 2 列,則一次閱讀 4 列。 通過他們的索引訪問。 假設它是一個 CSV 文件,
import csv
rows = []
with open('file.csv') as csvfile:
reader = csv.reader(csvfile, ...)
for row in reader:
item_amount1 = row[1:3]
item_amount2 = row[3:5]
rows.extend([item_amount1, item_amount2])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.