Python不会读取CSV文件的所有行

时间:2019-06-27 07:13:10

标签: python text-files export-to-csv

00,0,6098
00,1,6098
00,2,6098
00,3,6098
00,4,6094
00,5,6094
00,6,6094
00,7,6094
00,8,6094

这是我的csv文件的片段。该文件包含大约465行,但当我阅读时,仅读取380行。这是我的代码:

import csv
import itertools
 with open('lala.csv', 'r') as in_file:
    lines = in_file.read().splitlines()
    stripped = [line.replace(","," ").split() for line in lines]
    grouped = itertools.izip(*[stripped]*1)
    with open('lala.csv', 'w') as out_file:
        writer = csv.writer(out_file)
        for group in grouped:
            writer.writerows(group)
file=open( "lala.csv", "r")
reader = csv.reader(file)
for line in reader:
    print(line[2])

0 个答案:

没有答案