とValueError:私はエラーに取得するフィールドのテキストと日付 と私のcsvファイルを読み込むしようとすると 'テキスト' はリスト
ではありません
text_column_index = header.index('text')
ValueError: 'text' is not in list
コード:
with open(source_file_path, 'r') as input_file:
csv_reader = csv.reader(input_file, delimiter='\t')
header = next(csv_reader)
text_column_index = header.index('text')
date_column_index = header.index('date')
word_frequency = {}
for line in csv_reader:
self.size += 1
words = self.tokenize(line[text_column_index])
date = line[date_column_index]
if date > self.end_date:
self.end_date = date
elif date < self.start_date:
self.start_date = date
私は何が間違っていますか?
'print(header)'を追加し、その内容を確認してください。 –
何も起こらないhmm – Silas
文字通り何も起こりませんか?少なくとも空のリストを印刷する必要があるようです。 –