Solved: python for skip header line

The main problem with skipping a header line in Python is that it can cause errors when the program tries to access variables or functions that are not on the first line of the file.

 in csv

There is no built-in function in Python to skip the header line of a CSV file, but the following code will accomplish what you want:

import csv with open('input.csv', 'rb') as f: reader = csv.reader(f) for row in reader: if row[0] != 'header': print row

This code will open the input.csv file, create a CSV reader object, and loop through the rows in the file. If the first element in a row is not equal to ‘header’, the row will be printed.

Header line

The header line in Python is the first line of a source file. It consists of the name of the file followed by a colon and the filename extension.

Skip elements

In Python, a Skip element is a special type of list that skips over the first n elements of a list.

Related posts:

Leave a Comment