1

我需要读取一个没有 11 个标题行的制表符分隔的 csv 文件,如下所示。我怎样才能在python中做到这一点?

START:  21.09.2011  11:24:12

TIME STEP:
100 = 10s

VOLTAGE RANGE:
CH1:  255 = 3V  CH3:  255 = 30V
CH2:  255 = 30V CH4:  255 = 30V

N   CH1 Time/s  CH1/V   CH2/V   CH3/V   CH4/V

0   137 0,00    1,612   0,000   0,000   0,000
1   137 0,10    1,612   0,000   0,000   0,000
2   137 0,20    1,612   0,000   0,000   0,000
3   131 0,30    1,541   0,000   0,000   0,000
...

非常感谢奥托

4

1 回答 1

2

您可以使用itertools.islice

import csv
import itertools

with open('1.csv') as f:
    lines = itertools.islice(f, 11, None) # skip 11 lines, similar to [11:]
    reader = csv.reader(lines)
    for row in reader:
        ... Do whatever you want with row ..
于 2013-10-14T15:54:11.617 回答