0
我正在使用python內置csv包,我需要找到一個「更智能」的方式來查找特定列及其索引。使用python查找CSV中的列號
目前我手動計數列號,但我的文件不斷更改列號和無法計數列號了。
這是到目前爲止我的代碼
import csv
url_column_index = ""
#the column title i need is url
p = open('my-great-file.csv')
csv_f = csv.reader(p)
for row in csv_f:
if row[3] == 'url':
# set url_column_index