For循环未初始化

时间:2018-12-14 11:00:39

标签: python python-3.x

我正在尝试从CSV文件中读取特定的列。一切运行正常,但显然for循环无法正常工作。也就是说,当我尝试在for loop中打印“ in else”时,我什么也没得到。

with open(path) as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    row_count = sum(1 for line in csv_file)
    print(row_count)
    companyName = [None]*row_count
    reportID = [None]*row_count
    date = [None]*row_count
    line_count = 1
    print(line_count)
    for row in csv_reader:
        print('in else')
        companyName[line_count-1] = row[1]
        print(row[1])
        reportID[line_count-1] = row[2]
        date[line_count-1] = row[4]
        line_count += 1

0 个答案:

没有答案