0

「国」などの特定の列がファイルに存在しない場合のエラーを防ぐ方法は?

import csv
files = glob.glob ('..\\*.csv')
for file in files:
    countries = []
    with open ('data.csv', newline='') as infile:
        reader = csv.DictReader(infile)
        for row in reader:
            countries.append(row['Country'])
    print (countries)
4

1 に答える 1