Reading past the first three lines of a cvs file in python [duplicate]

A couple of slight modifications will help:

def open_temperature_file(filename):
    full_text = []
    csv_file = open(filename, 'r')

    reader = csv.reader(csv_file)
    for line in reader:
        full_text.append(line)
    return full_text[3:] # return lines, starting from line 3

On the return above, I used a list slice to discard the first couple of lines.

Leave a Comment