Read file from line 2 or skip header row Read file from line 2 or skip header row python python

Read file from line 2 or skip header row


with open(fname) as f:    next(f)    for line in f:        #do something


f = open(fname,'r')lines = f.readlines()[1:]f.close()


If you want the first line and then you want to perform some operation on file this code will helpful.

with open(filename , 'r') as f:    first_line = f.readline()    for line in f:            # Perform some operations